1
This commit is contained in:
@@ -1,91 +1,68 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<div class="header bottomShadow">
|
||||
<div class="header bottomShadow" :class="{ 'mini': isMiniHeader }">
|
||||
<div class="content pageWidth">
|
||||
<div class="top">
|
||||
<div class="content bread">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="contact contactLinks">
|
||||
<img src="../assets/img/svg/mobile.svg" class="inlineTextIcon inlineTextPhoneIcon"><span>
|
||||
<a href="tel:13817819452">13817819452</a></span> <img src="../assets/img/svg/airplane.svg" class="inlineTextIcon">
|
||||
<span><a href="mailto:bimwe@bimwe.com">bimwe@bimwe.com</a></span>
|
||||
</td>
|
||||
<td class="searchContainer desktop">
|
||||
<input type="text" class="search" placeholder="Sök" style="margin-left:1em;width:10em">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- 主要导航区域 -->
|
||||
<div class="bottom desktop">
|
||||
<div class="nav-container">
|
||||
<div class="logoCell">
|
||||
<img class="logo" :src="image_paths.logo" alt="丙维科技">
|
||||
</div>
|
||||
<div class="mainMenuCell">
|
||||
<nav class="mainMenu">
|
||||
<div class="nav-item" v-for="menu in menus" :key="menu.name">
|
||||
<router-link :to="menu.url" class="nav-link">
|
||||
{{menu.name}}
|
||||
<span v-if="menu.child.length>0" class="downCaret"></span>
|
||||
</router-link>
|
||||
<div class="dropDown bottomShadowSegment" v-if="menu.child.length>0">
|
||||
<router-link
|
||||
:to="sonMenu.url"
|
||||
v-for="sonMenu in menu.child"
|
||||
:key="sonMenu.name"
|
||||
class="dropdown-item"
|
||||
>
|
||||
{{sonMenu.name}}
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- BOTTOM - DESKTOP -->
|
||||
<div class="bottom desktop">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="logoCell">
|
||||
<img class="logo" src="../assets/img/logo.png">
|
||||
</td>
|
||||
<td class="mainMenuCell">
|
||||
<table class="mainMenu">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="h2" v-for="menu in menus" :key="menu.name">
|
||||
<router-link :to="menu.url">
|
||||
{{menu.name}}
|
||||
<span v-if="menu.child.length>0" class="downCaret"></span>
|
||||
</router-link>
|
||||
<div class="dropDown bottomShadowSegment" v-if="menu.child.length>0">
|
||||
<router-link :to="sonMenu.url" v-for="sonMenu in menu.child" :key="sonMenu.name">{{sonMenu.name}}</router-link>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END BOTTOM - DESKTOP -->
|
||||
|
||||
<!-- 移动端导航 -->
|
||||
<div class="bottom headerBottom mobile">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="logoCell">
|
||||
<img class="logo" src="../assets/img/bimwe_logo.png">
|
||||
</td>
|
||||
<td class="mobileIconsCell">
|
||||
<!-- <img src="../assets/img/svg/ic_search.svg" /> -->
|
||||
<img src="../assets/img/svg/ic_hamburger.svg" id="hamburger">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="mobile-nav">
|
||||
<div class="logoCell">
|
||||
<img class="logo" :src="image_paths.mobile_logo" alt="丙维科技">
|
||||
</div>
|
||||
<div class="mobileIconsCell">
|
||||
<img :src="image_paths.hamburger" id="hamburger" alt="菜单">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 移动端菜单 -->
|
||||
<div id="mobileMenu" class="headerMobileMenu bread">
|
||||
<div class="menuDummy"></div>
|
||||
<div class="menuContent">
|
||||
<ul>
|
||||
<li v-for="menu in menus" :key="menu.name">
|
||||
<a href="menu.url" v-if="menu.name=='首页'">{{menu.name}}</a>
|
||||
<router-link :to="menu.url" v-if="menu.name=='首页'">{{menu.name}}</router-link>
|
||||
<label v-else class="hasSubmenu" style="display:block;">{{menu.name}}</label>
|
||||
<ul class="subMenu" v-if="menu.child.length>0">
|
||||
<li v-for="sonMenu in menu.child" :key="sonMenu.name">
|
||||
<li v-for="sonMenu in menu.child" :key="sonMenu.name">
|
||||
<router-link class="hasSubmenu" :to="sonMenu.url">{{sonMenu.name}}</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<div class="goBack">
|
||||
<a href="JavaScript:void()" class="linkGoBack flexVerticalCenter">
|
||||
<img src="../assets/img/svg/ic_arrow_back.svg" alt="返回">
|
||||
<img :src="image_paths.arrow_back" alt="返回">
|
||||
<span>返回</span>
|
||||
</a>
|
||||
</div>
|
||||
@@ -94,26 +71,711 @@
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { common } from '../static/common'
|
||||
|
||||
export default {
|
||||
name: 'ihead',
|
||||
data() {
|
||||
return {
|
||||
menus: window.config.menus
|
||||
isMiniHeader: false,
|
||||
menus: [
|
||||
{
|
||||
name: '首页',
|
||||
url: '/index',
|
||||
child: []
|
||||
},
|
||||
{
|
||||
name: '关于我们',
|
||||
url: '/aboutUs/aboutUs',
|
||||
child: []
|
||||
},
|
||||
{
|
||||
name: '我们的方案',
|
||||
url: '/ourPlan/ourPlan',
|
||||
child: [
|
||||
{ name: '智能建筑', url: '/ourPlan/estateManagement' },
|
||||
{ name: '物联网', url: '/ourPlan/iot' },
|
||||
{ name: '设施管理', url: '/ourPlan/facilityManagement' },
|
||||
{ name: 'AI解决方案', url: '/ourPlan/aiSolutions' },
|
||||
{ name: '技术集成', url: '/ourPlan/technologyIntegration' }
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
common.init()
|
||||
common.initListeners()
|
||||
common.initHeader()
|
||||
common.initForms()
|
||||
common.initMobileMenu()
|
||||
common.adjustElementsForScreen()
|
||||
computed: {
|
||||
// 统一管理图片路径,提高可维护性
|
||||
image_paths() {
|
||||
return {
|
||||
logo: require('@/assets/img/logo.png'),
|
||||
mobile_logo: require('@/assets/img/bimwe_logo.png'),
|
||||
hamburger: require('@/assets/img/svg/ic_hamburger.svg'),
|
||||
arrow_back: require('@/assets/img/svg/ic_arrow_back.svg')
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.initHeader()
|
||||
this.initScrollListener()
|
||||
},
|
||||
methods: {
|
||||
// 封装事件监听器创建,提高代码复用性
|
||||
add_event_listener(selector, event_type, callback, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.addEventListener(event_type, callback);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// 封装类名操作,提高代码复用性
|
||||
toggle_class(selector, class_name, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.classList.toggle(class_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// 封装类名添加,提高代码复用性
|
||||
add_class(selector, class_name, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.classList.add(class_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// 封装类名移除,提高代码复用性
|
||||
remove_class(selector, class_name, use_id = false) {
|
||||
const element = use_id ? document.getElementById(selector) : document.querySelector(selector);
|
||||
if (element) {
|
||||
element.classList.remove(class_name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
initHeader() {
|
||||
// 点击logo返回首页
|
||||
this.add_event_listener(".logoCell .logo", "click", () => {
|
||||
if (window.location.href.indexOf("index") === -1) {
|
||||
window.location.href = "#/index";
|
||||
}
|
||||
});
|
||||
|
||||
// 移动端菜单切换
|
||||
this.add_event_listener("hamburger", "click", () => {
|
||||
this.toggle_class("mobileMenu", "active", true);
|
||||
}, true);
|
||||
|
||||
// 返回按钮
|
||||
this.add_event_listener(".linkGoBack", "click", () => {
|
||||
this.remove_class("mobileMenu", "active", true);
|
||||
// 关闭移动端菜单后滚动到顶部
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
left: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
initScrollListener() {
|
||||
window.addEventListener('scroll', () => {
|
||||
if (window.pageYOffset > 200) {
|
||||
if (!this.isMiniHeader) {
|
||||
this.isMiniHeader = true;
|
||||
this.add_class('.header', 'mini');
|
||||
}
|
||||
} else {
|
||||
if (this.isMiniHeader) {
|
||||
this.isMiniHeader = false;
|
||||
this.remove_class('.header', 'mini');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
||||
<style scoped>
|
||||
/* 使用更高优先级覆盖 common.css 的样式 */
|
||||
/* 重置旧表格布局样式 */
|
||||
.header table,
|
||||
.header table tbody,
|
||||
.header table tbody tr,
|
||||
.header table tbody tr td {
|
||||
display: block !important;
|
||||
width: auto !important;
|
||||
height: auto !important;
|
||||
border: none !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
/* 头部基础样式 - 使用 !important 覆盖 common.css */
|
||||
.header {
|
||||
position: fixed !important;
|
||||
top: 0 !important;
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
z-index: 1000 !important;
|
||||
background: rgba(255, 255, 255, 0.95) !important;
|
||||
backdrop-filter: blur(10px) !important;
|
||||
transition: all var(--transition-speed) ease !important;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
|
||||
/* 覆盖旧表格布局 */
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.header.mini {
|
||||
background: rgba(255, 255, 255, 0.98) !important;
|
||||
box-shadow: var(--shadow-light) !important;
|
||||
}
|
||||
|
||||
/* 顶部联系信息 - 覆盖旧样式 */
|
||||
.top {
|
||||
background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
|
||||
padding: 8px 0 !important;
|
||||
/* 覆盖旧表格布局 */
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.contact-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.contact-item:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.contact-item a {
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.inlineTextIcon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
filter: brightness(0) invert(1);
|
||||
}
|
||||
|
||||
/* 搜索框 */
|
||||
.search {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 20px;
|
||||
padding: 6px 15px;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.search::placeholder {
|
||||
color: rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
.search:focus {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-color: rgba(255, 255, 255, 0.5);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* 主要导航区域 - 覆盖旧样式 */
|
||||
.bottom {
|
||||
padding: 15px 0 !important;
|
||||
/* 覆盖旧表格布局 */
|
||||
display: block !important;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.nav-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.logoCell .logo {
|
||||
height: 50px;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.logoCell .logo:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
/* 主导航菜单 */
|
||||
.mainMenu {
|
||||
display: flex;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
display: block;
|
||||
padding: 15px 25px;
|
||||
color: #2c3e50;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
font-size: 16px;
|
||||
transition: all 0.3s ease;
|
||||
border-radius: var(--border-radius);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
color: #3498db;
|
||||
background: rgba(52, 152, 219, 0.1);
|
||||
}
|
||||
|
||||
.nav-link::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 50%;
|
||||
width: 0;
|
||||
height: 2px;
|
||||
background: #3498db;
|
||||
transition: all 0.3s ease;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.nav-link:hover::after {
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
/* 下拉菜单 */
|
||||
.dropDown {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 0;
|
||||
background: white;
|
||||
border-radius: var(--border-radius);
|
||||
box-shadow: var(--shadow-medium);
|
||||
padding: 15px 0;
|
||||
min-width: 200px;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-10px);
|
||||
transition: all 0.3s ease;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.nav-item:hover .dropDown {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
display: block;
|
||||
padding: 12px 25px;
|
||||
color: #2c3e50;
|
||||
text-decoration: none;
|
||||
transition: all 0.3s ease;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.dropdown-item:hover {
|
||||
background: rgba(52, 152, 219, 0.1);
|
||||
color: #3498db;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
/* 下拉箭头 */
|
||||
.downCaret {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.nav-item:hover .downCaret {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* 移动端导航 */
|
||||
.mobile-nav {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.mobile .logo {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
#hamburger {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
cursor: pointer;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
#hamburger:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
/* 移动端菜单 */
|
||||
.headerMobileMenu {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
transition: left 0.3s ease;
|
||||
z-index: 1001;
|
||||
}
|
||||
|
||||
.headerMobileMenu.active {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.menuContent {
|
||||
background: white;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.menuContent ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.menuContent li {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.menuContent a,
|
||||
.menuContent label {
|
||||
display: block;
|
||||
padding: 15px;
|
||||
color: #2c3e50;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
border-radius: var(--border-radius);
|
||||
transition: all var(--transition-speed) ease;
|
||||
}
|
||||
|
||||
.menuContent a:hover,
|
||||
.menuContent label:hover {
|
||||
background: rgba(52, 152, 219, 0.1);
|
||||
color: #3498db;
|
||||
}
|
||||
|
||||
.subMenu {
|
||||
margin-left: 20px;
|
||||
border-left: 2px solid #e9ecef;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
.goBack {
|
||||
margin-top: 30px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.linkGoBack {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: #6c757d;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.linkGoBack:hover {
|
||||
color: #3498db;
|
||||
}
|
||||
|
||||
/* 现代响应式设计 - 使用容器查询和逻辑属性 */
|
||||
/* 基础响应式容器 */
|
||||
.header {
|
||||
container-type: inline-size;
|
||||
container-name: header;
|
||||
}
|
||||
|
||||
/* 使用容器查询替代媒体查询 */
|
||||
@container header (max-width: 768px) {
|
||||
.desktop {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.mobile {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
flex-direction: column !important;
|
||||
gap: 10px !important;
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
|
||||
.searchContainer {
|
||||
width: 100% !important;
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
.search {
|
||||
width: 100% !important;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
/* 移动端头部高度调整 */
|
||||
.header {
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.header .content {
|
||||
padding: 0 1em !important;
|
||||
}
|
||||
}
|
||||
|
||||
@container header (min-width: 769px) {
|
||||
.mobile {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.desktop {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用逻辑属性实现更好的国际化支持 */
|
||||
.header .content {
|
||||
padding-inline: 3em;
|
||||
padding-block: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.header .content {
|
||||
padding-inline: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用 CSS Grid 实现更灵活的布局 */
|
||||
.nav-container {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 2rem;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
@container header (max-width: 768px) {
|
||||
.nav-container {
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用 CSS 自定义属性实现主题切换 */
|
||||
:root {
|
||||
--header-bg: rgba(255, 255, 255, 0.95);
|
||||
--header-border: rgba(0, 0, 0, 0.1);
|
||||
--nav-hover-bg: rgba(52, 152, 219, 0.1);
|
||||
--nav-hover-color: #3498db;
|
||||
}
|
||||
|
||||
/* 深色主题支持 */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--header-bg: rgba(30, 30, 30, 0.95);
|
||||
--header-border: rgba(255, 255, 255, 0.1);
|
||||
--nav-hover-bg: rgba(52, 152, 219, 0.2);
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用 CSS 自定义属性 */
|
||||
.header {
|
||||
background: var(--header-bg) !important;
|
||||
border-bottom: 1px solid var(--header-border) !important;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background: var(--nav-hover-bg) !important;
|
||||
color: var(--nav-hover-color) !important;
|
||||
}
|
||||
|
||||
/* 现代动画效果 - 使用 CSS 自定义属性和性能优化 */
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用 will-change 优化动画性能 */
|
||||
.nav-item {
|
||||
will-change: transform, opacity;
|
||||
}
|
||||
|
||||
/* 使用 CSS 自定义属性控制动画延迟 */
|
||||
.nav-item {
|
||||
animation: slideDown 0.5s ease forwards;
|
||||
animation-delay: calc(var(--animation-index, 0) * 0.1s);
|
||||
}
|
||||
|
||||
/* 使用 CSS 计数器自动生成动画延迟 */
|
||||
.nav-item:nth-child(1) { --animation-index: 1; }
|
||||
.nav-item:nth-child(2) { --animation-index: 2; }
|
||||
.nav-item:nth-child(3) { --animation-index: 3; }
|
||||
.nav-item:nth-child(4) { --animation-index: 4; }
|
||||
|
||||
/* 使用 CSS 逻辑属性实现更好的动画方向 */
|
||||
@keyframes slideInFromStart {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(-20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 支持 RTL 的动画 */
|
||||
[dir="rtl"] .nav-item {
|
||||
animation: slideInFromStart 0.5s ease forwards;
|
||||
}
|
||||
|
||||
/* 使用现代 CSS 实现内容间距 */
|
||||
/* 使用 CSS 自定义属性定义头部高度 */
|
||||
:root {
|
||||
--header-height: 120px;
|
||||
--header-height-mobile: 100px;
|
||||
|
||||
/* 添加更多主题变量 */
|
||||
--transition-speed: 0.3s;
|
||||
--border-radius: 8px;
|
||||
--shadow-light: 0 2px 20px rgba(0, 0, 0, 0.1);
|
||||
--shadow-medium: 0 10px 30px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
/* 容器查询回退方案 - 为不支持容器查询的浏览器提供媒体查询 */
|
||||
@supports not (container-type: inline-size) {
|
||||
@media (max-width: 768px) {
|
||||
.desktop {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.mobile {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.contact-info {
|
||||
flex-direction: column !important;
|
||||
gap: 10px !important;
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
|
||||
.searchContainer {
|
||||
width: 100% !important;
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
.search {
|
||||
width: 100% !important;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
.header {
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
.header .content {
|
||||
padding: 0 1em !important;
|
||||
}
|
||||
|
||||
body {
|
||||
padding-top: 100px !important;
|
||||
}
|
||||
|
||||
.nav-container {
|
||||
grid-template-columns: 1fr auto !important;
|
||||
gap: 1rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 769px) {
|
||||
.mobile {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.desktop {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用逻辑属性确保内容不被遮挡 */
|
||||
body {
|
||||
padding-block-start: var(--header-height) !important;
|
||||
}
|
||||
|
||||
/* 使用容器查询替代媒体查询 */
|
||||
@container header (max-width: 768px) {
|
||||
body {
|
||||
padding-block-start: var(--header-height-mobile) !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* 使用 CSS 逻辑属性实现更好的 RTL 支持 */
|
||||
.header {
|
||||
inset-block-start: 0;
|
||||
inset-inline: 0;
|
||||
}
|
||||
|
||||
/* 使用 CSS 逻辑属性实现更好的间距 */
|
||||
.contact-info {
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.nav-container {
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
/* 使用 CSS 逻辑属性实现更好的边框 */
|
||||
.header {
|
||||
border-block-end: 1px solid var(--header-border) !important;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
animation: slideDown 0.5s ease forwards;
|
||||
}
|
||||
|
||||
.nav-item:nth-child(1) { animation-delay: 0.1s; }
|
||||
.nav-item:nth-child(2) { animation-delay: 0.2s; }
|
||||
.nav-item:nth-child(3) { animation-delay: 0.3s; }
|
||||
.nav-item:nth-child(4) { animation-delay: 0.4s; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user