diff --git a/templates/assets/css/style.css b/templates/assets/css/style.css index 53a2780..d467963 100644 --- a/templates/assets/css/style.css +++ b/templates/assets/css/style.css @@ -83,7 +83,7 @@ h6, } #header.header-scrolled { - background: none; + background: #ffffffc9; height: 60px; } @@ -121,14 +121,19 @@ h6, */ .navbar { padding: 0; + width: 100%; + position: relative; } -.navbar ul { - margin: 0; +.navbar > ul.navbar-nav { + margin: 0 auto; padding: 0; display: flex; list-style: none; align-items: center; + justify-content: center; + width: auto; + max-width: 1200px; } .navbar li { @@ -139,8 +144,8 @@ h6, .navbar a:focus { display: flex; align-items: center; - justify-content: space-between; - padding: 10px 0 10px 30px; + justify-content: center; + padding: 15px 25px; font-family: "Open Sans", sans-serif; font-size: 14px; color: #000000; @@ -148,13 +153,6 @@ h6, transition: 0.3s; } -.navbar a i, -.navbar a:focus i { - font-size: 12px; - line-height: 0; - margin-left: 5px; -} - .navbar a:hover, .navbar .active, .navbar .active:focus, @@ -162,71 +160,138 @@ h6, color: #34C5DD; } -.navbar .dropdown ul { - display: block; +/* 下拉菜单样式 - 铺满屏幕宽度 */ +.navbar .dropdown-menu { position: absolute; - left: 14px; - top: calc(100% + 30px); - margin: 0; - padding: 10px 0; - z-index: 99; + left: 50%; /* 关键修改:从左侧50%位置开始 */ + transform: translateX(-40%); /* 关键修改:向左回退50%自身宽度 */ + top: 100%; + width: 50%; /* 改为自动宽度 */ + min-width: 600px; /* 设置最小宽度 */ + display: block; /* 改为block布局 */ + background: #fff; + padding: 15px 0; + box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1); opacity: 0; visibility: hidden; - background: #fff; - box-shadow: 0px 0px 30px rgba(127, 137, 161, 0.25); - transition: 0.3s; + transition: opacity 0.3s ease-in-out; + z-index: 1000; } -.navbar .dropdown ul li { - min-width: 200px; +/* 下拉菜单容器 */ +.navbar .dropdown-menu > ul { + display: flex; + width: 100%; + max-width: 1200px; + margin: 0 auto; + padding: 0 15px; + justify-content: space-around; } -.navbar .dropdown ul a { - padding: 10px 20px; - font-size: 14px; - text-transform: none; - color: #1c3745; +/* 下拉菜单项 */ +.navbar .dropdown-menu li { + text-align: center; + min-width: 0; } -.navbar .dropdown ul a i { - font-size: 12px; +/* 修改这里:二级菜单链接始终显示下划线 */ +.navbar .dropdown-menu a { + padding: 8px 5px; + display: block; + color: #333; + text-decoration: underline; /* 始终显示下划线 */ + text-underline-offset: 10px; /* 下划线距离文字的距离 */ + text-decoration-color: rgba(0, 0, 0, 0.3); /* 下划线颜色稍浅 */ + white-space: normal; + transition: all 0.3s; } -.navbar .dropdown ul a:hover, -.navbar .dropdown ul .active:hover, -.navbar .dropdown ul li:hover>a { - color: #68A4C4; +/* 悬停时下划线颜色加深 */ +.navbar .dropdown-menu a:hover { + color: #007bff; + text-decoration-color: #007bff; /* 悬停时下划线颜色变深 */ } -.navbar .dropdown:hover>ul { +.navbar .nav-item:hover .dropdown-menu { opacity: 1; - top: 100%; visibility: visible; } -.navbar .dropdown .dropdown ul { - top: 0; - left: calc(100% - 30px); - visibility: hidden; -} - -.navbar .dropdown .dropdown:hover>ul { - opacity: 1; - top: 0; - left: 100%; - visibility: visible; -} - -@media (max-width: 1366px) { - .navbar .dropdown .dropdown ul { - left: -90%; +/* 响应式设计 */ +@media (max-width: 768px) { + .navbar > ul.navbar-nav { + flex-direction: column; } - - .navbar .dropdown .dropdown:hover>ul { - left: -100%; + + .navbar .dropdown-menu { + position: static; + width: 100%; + margin-left: 0; + display: none; + } + + .navbar .nav-item:hover .dropdown-menu { + display: flex; + } + + .navbar .dropdown-menu > ul { + flex-direction: column; + } + + /* 移动端下划线样式 */ + .navbar .dropdown-menu a { + text-underline-offset: 3px; + padding: 8px 0; } } +.navbar-nav > li > .dropdown-toggle::after { + display: none; +} + +/* 原有样式保持不变,添加以下新样式 */ + +/* 三级菜单容器 */ +.navbar .dropdown-submenu { + position: relative; +} + +/* 三级菜单链接样式 - 移除了下划线 */ +.navbar .dropdown-menu .third-level a { + padding: 8px 15px 8px 1px; /* 增加左边距表示层级 */ + color: #666; + text-decoration: none; /* 移除了下划线 */ +} + +/* 三级菜单悬停效果 */ +.navbar .dropdown-menu .third-level a:hover { + color: #007bff; + text-decoration: none; /* 确保悬停时也没有下划线 */ + background-color: rgba(0, 0, 0, 0.05); /* 添加轻微背景色变化 */ +} + +/* 三级菜单链接样式 */ +.navbar .dropdown-menu.third-level a { + padding: 8px 15px 8px 30px; /* 增加左边距表示层级 */ + color: #666; + text-decoration: underline; + text-underline-offset: 4px; + text-decoration-color: rgba(0, 0, 0, 0.2); +} + +/* 响应式设计 - 移动端 */ +@media (max-width: 768px) { + .navbar .dropdown-menu.third-level { + padding-left: 20px; /* 移动端增加缩进 */ + background-color: #f5f5f5; + } + + .navbar .dropdown-menu.third-level a { + padding-left: 40px; /* 更大的缩进 */ + } +} + + /** * Mobile Navigation */ diff --git a/templates/modules/header.html b/templates/modules/header.html index 053cef3..63b50ae 100644 --- a/templates/modules/header.html +++ b/templates/modules/header.html @@ -15,49 +15,7 @@ - - + + \ No newline at end of file diff --git a/templates/modules/navbar.html b/templates/modules/navbar.html new file mode 100644 index 0000000..c93e250 --- /dev/null +++ b/templates/modules/navbar.html @@ -0,0 +1,42 @@ + \ No newline at end of file