顶部菜单栏响应式
This commit is contained in:
parent
ab355594ef
commit
bac7d19682
@ -1,3 +1,19 @@
|
|||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
||||||
|
/* header.component.css */
|
||||||
|
.flex {
|
||||||
|
/* 标题栏的通用样式 */
|
||||||
|
/* ... */
|
||||||
|
|
||||||
|
/* 响应式布局样式 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 媒体查询样式 */
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.flex {
|
||||||
|
/* 在移动设备上的样式 */
|
||||||
|
/* ... */
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import {Component} from '@angular/core';
|
import { Component, HostListener, OnInit } from '@angular/core';
|
||||||
import {NgOptimizedImage} from '@angular/common';
|
import { NgOptimizedImage } from '@angular/common';
|
||||||
import {RouterLink} from "@angular/router";
|
import { RouterLink } from "@angular/router";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@ -9,5 +9,26 @@ import {RouterLink} from "@angular/router";
|
|||||||
styleUrls: ['./top-bar.component.scss'],
|
styleUrls: ['./top-bar.component.scss'],
|
||||||
imports: [NgOptimizedImage, RouterLink],
|
imports: [NgOptimizedImage, RouterLink],
|
||||||
})
|
})
|
||||||
export class TopBarComponent {
|
export class TopBarComponent implements OnInit {
|
||||||
|
isMobile: boolean = false;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:resize', ['$event'])
|
||||||
|
onResize(event: Event) {
|
||||||
|
this.updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.updateLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLayout() {
|
||||||
|
const screenWidth = window.innerWidth;
|
||||||
|
this.isMobile = screenWidth < 768;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user