hexo-theme-wang
Version:
a hexo theme minimalism
251 lines (223 loc) • 6.27 kB
text/stylus
header {
position: fixed;
z-index: 1000;
top: 0; // 始终保持在顶部
left: 0;
right: 0;
width: 100%;
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
background-color: rgba(0, 0, 0, 0.11);
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
box-shadow: 0 2px 20px rgba(0, 0, 0, 0.15);
font-family: 'DouyinSans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
transition: transform 0.3s ease;
height: 60px; // 固定高度
// 导航容器
nav {
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
}
// 菜单列表 - 强制横向显示且不换行
ul {
list-style: none;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
flex-wrap: nowrap; // 修改:不允许换行
gap: 1rem;
padding: 0.5rem 1rem;
margin: 0;
overflow-x: auto; // 添加横向滚动以适应小屏幕
scrollbar-width: none; // 隐藏滚动条(Firefox)
-ms-overflow-style: none; // 隐藏滚动条(IE/Edge)
&::-webkit-scrollbar {
display: none; // 隐藏滚动条(Chrome/Safari)
}
}
li {
position: relative;
padding: 0.3rem 0.5rem; // 减小内边距
transition: all 0.3s ease;
flex-shrink: 0; // 防止项目被压缩
}
a, button.search-toggle-btn {
position: relative;
text-decoration: none;
color: #e1e1ff;
font-weight: 500;
padding: 0.25rem 0;
display: inline-flex;
align-items: center;
font-size: 1.1rem; // 稍微减小字体大小,方便移动端显示
white-space: nowrap; // 强制文字不换行
background: none;
border: none;
cursor: pointer;
&::before {
content: '';
position: absolute;
bottom: -2px;
left: 0;
width: 0;
height: 2px;
background: linear-gradient(90deg, #00ffff, #66ffff);
transition: width 0.3s ease-in-out;
}
&:hover, &.active {
color: #fff;
&::before {
width: 100%;
}
}
}
.menu-icon {
width: 22px;
height: 22px;
vertical-align: middle;
margin-right: 8px;
}
// 汉堡菜单按钮调整
.hamburger {
display: none; // 大屏幕下隐藏
flex-direction: column;
justify-content: space-between;
width: 25px;
height: 18px;
position: absolute;
right: 20px;
top: 20px;
cursor: pointer;
z-index: 100;
padding: 10px;
background: none;
border: none;
span {
display: block;
height: 2px;
width: 100%;
background-color: #e1e1ff;
border-radius: 2px;
transition: all 0.3s ease;
}
&.active {
span:nth-child(1) {
transform: translateY(8px) rotate(45deg);
}
span:nth-child(2) {
opacity: 0;
}
span:nth-child(3) {
transform: translateY(-8px) rotate(-45deg);
}
}
}
}
// 修改响应式设计,保持菜单横向显示
@media (max-width: 768px) {
header {
ul {
flex-direction: column; // 垂直排列菜单项
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: rgba(10, 10, 15, 0.95);
backdrop-filter: blur(15px);
-webkit-backdrop-filter: blur(15px);
padding: 4rem 1rem 2rem;
gap: 1.2rem;
transform: translateY(-100%);
transition: transform 0.3s ease;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
z-index: 5;
flex-wrap: nowrap; // 确保不换行
overflow-y: auto; // 添加纵向滚动以适应很多菜单项
max-height: 80vh; // 限制最大高度
}
ul.active {
transform: translateY(0);
}
.hamburger {
display: flex; // 小屏幕上显示汉堡菜单
top: 15px; // 位置调整
}
li {
width: 100%; // 每个菜单项占满宽度
text-align: center;
padding: 0.5rem 0;
}
a, button.search-toggle-btn {
justify-content: center; // 文字居中
width: auto; // 宽度自适应内容
display: inline-flex; // 内联弹性布局
font-size: 1.1rem; // 保持合适的字体大小
padding: 0.25rem 1rem; // 添加水平内边距
white-space: nowrap; // 再次确认文字不换行
.menu-icon {
width: 20px;
height: 20px;
margin-right: 8px;
}
&::before {
bottom: -3px;
}
}
}
}
// 滚动时隐藏导航
header.scroll-down {
transform: translateY(-100%);
}
// 搜索结果样式保持不变
#search-results {
position: absolute;
top: 60px;
left: 50%;
transform: translateX(-50%);
width: 80%;
max-width: 600px;
background: rgba(0, 0, 0, 0.8);
border-radius: 5px;
padding: 1rem;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
z-index: 1000;
display: none;
}
.search-result-item {
margin-bottom: 1rem;
}
.search-result-item a {
color: #00ffff;
text-decoration: none;
}
.search-result-item a:hover {
text-decoration: underline;
}
@keyframes pulse {
0% {
transform: scale(1);
opacity: 0.8;
}
50% {
transform: scale(1.3); // 增大缩放比例
opacity: 1;
}
100% {
transform: scale(1);
opacity: 0.8;
}
}
@keyframes breathing {
0% {
filter: drop-shadow(0 0 3px rgba(66,185,231,0.3));
}
50% {
filter: drop-shadow(0 0 15px rgba(66,185,231,1)); // 增强发光效果
}
100% {
filter: drop-shadow(0 0 3px rgba(66,185,231,0.3));
}
}