hexo-theme-keep/source/css/layout/_partial/header.styl

306 lines
6.1 KiB
Stylus
Raw Permalink Normal View History

$logo-title-font-size = 2rem
$pc-search-icon-font-size = 1.5rem
$menu-bar-line-height = 2.5px
$logo-image-box-width = 46px
.header-wrapper {
display flex
align-items center
justify-content center
box-sizing border-box
width 100%
height 100%
padding-top $scroll-progress-bar-height
2022-10-14 17:56:32 +08:00
background var(--background-color-1)
hover-style(false, 0, 0)
.header-content {
position relative
z-index $z-index-5
display flex
flex-direction row
align-items center
justify-content space-between
width $main-content-width
max-width $content-max-width
height 100%
transition-t("max-width, width", "0, 0", "0.1, 0.1", "ease, ease")
2020-12-25 17:50:22 +08:00
&.has-first-screen {
max-width $has-fs-content-max-width
}
.has-toc & {
max-width $has-toc-content-max-width
2020-12-25 17:50:22 +08:00
}
2020-09-03 16:47:52 +08:00
2020-11-20 12:02:22 +08:00
+keep-tablet() {
width $main-content-width-tablet
2020-09-03 16:47:52 +08:00
}
2020-11-20 12:02:22 +08:00
+keep-mobile() {
width $main-content-width-mobile
2020-09-03 16:47:52 +08:00
}
.left {
display flex
align-items center
transition-t("transform", "0", "0.2", "linear")
2021-01-05 11:48:58 +08:00
.header-shrink & {
transform scale(0.72)
transform-origin left
}
if (hexo-config('base_info.logo_img') || hexo-config('style.logo')) {
.logo-image {
width $logo-image-box-width
height $logo-image-box-width
margin-right 8px
+keep-tablet() {
width $logo-image-box-width * 0.9
height $logo-image-box-width * 0.9
}
+keep-mobile() {
width $logo-image-box-width * 0.8
height $logo-image-box-width * 0.8
}
img {
width 100%
border-radius 6px
}
}
2021-01-05 11:48:58 +08:00
}
2020-12-01 16:51:38 +08:00
.logo-title {
2022-10-14 17:56:32 +08:00
color var(--text-color-1)
font-weight bold
font-size $logo-title-font-size
line-height 1
letter-spacing 1px
2020-06-04 22:11:27 +08:00
+keep-tablet() {
font-size $logo-title-font-size * 0.9
}
2020-06-04 22:11:27 +08:00
+keep-mobile() {
font-size $logo-title-font-size * 0.8
}
2020-06-04 22:11:27 +08:00
}
}
2021-01-04 21:16:07 +08:00
.right {
2020-11-15 22:06:32 +08:00
.pc {
2021-01-05 11:48:58 +08:00
.menu-list {
display flex
align-items center
+keep-tablet() {
display none
}
2020-09-03 16:47:52 +08:00
2020-12-01 16:51:38 +08:00
.menu-item {
position relative
float left
2022-09-30 11:36:38 +08:00
margin-left 2rem
2022-10-14 17:56:32 +08:00
color var(--text-color-3)
font-size 1rem
cursor pointer
&:first-child {
margin-left 0
}
a:hover
.active {
&::after {
position absolute
bottom -10px
left 50%
width 100%
height 2px
background var(--primary-color)
transform translateX(-50%)
content ''
transition-t("transform, bottom", "0, 0", "0.2, 0.2", "linear, linear")
2021-01-05 11:48:58 +08:00
.header-shrink & {
bottom -($header-shrink-height / 2 - 12)
2021-01-05 11:48:58 +08:00
}
}
}
&.search {
margin-left 26px
font-size $pc-search-icon-font-size
i {
2022-10-14 17:56:32 +08:00
color var(--text-color-3)
}
}
}
}
}
2021-01-05 11:48:58 +08:00
.mobile {
display flex
align-items center
justify-content space-between
.icon-item {
position relative
display none
width 20px
height 20px
margin-left 12px
2022-10-14 17:56:32 +08:00
color var(--text-color-3)
font-size 18px
cursor pointer
i {
2022-10-14 17:56:32 +08:00
color var(--text-color-3)
}
&:first-child {
margin-left 0
}
+keep-tablet() {
display flex
align-items center
justify-content center
}
}
.menu-bar {
2020-09-03 16:47:52 +08:00
.menu-bar-middle {
position relative
width 18px
height $menu-bar-line-height
2022-10-14 17:56:32 +08:00
background var(--text-color-3)
2020-04-01 22:42:24 +08:00
2021-01-05 11:48:58 +08:00
.header-drawer-show & {
background transparent
2021-01-05 11:48:58 +08:00
}
&::before
&::after {
position absolute
left 0
width 100%
height $menu-bar-line-height
2022-10-14 17:56:32 +08:00
background var(--text-color-3)
content ''
transition-t("transform", "0", "0.38", "ease")
}
2021-01-05 11:48:58 +08:00
&::before {
top -6px
2021-01-05 11:48:58 +08:00
.header-drawer-show & {
transform translateY(6px) rotate(45deg)
2021-01-05 11:48:58 +08:00
}
}
&::after {
bottom -6px
2021-01-05 11:48:58 +08:00
.header-drawer-show & {
transform translateY(-6px) rotate(-45deg)
2021-01-05 11:48:58 +08:00
}
}
}
2020-04-01 22:42:24 +08:00
}
}
}
}
.header-drawer {
position absolute
top 0
left 0
z-index $z-index-2
width 100%
padding $header-height 0 20px 0
2022-10-14 17:56:32 +08:00
background var(--background-color-1)
transform scaleY(0)
transform-origin top
transition-t("transform", "0", "0.38", "ease")
2020-12-01 16:51:38 +08:00
2021-01-05 11:48:58 +08:00
.header-drawer-show & {
transform scaleY(1)
2021-01-05 11:48:58 +08:00
}
.drawer-menu-list {
display flex
flex-direction column
align-items center
justify-content flex-start
.drawer-menu-item {
height 38px
margin 6px 0
font-size 1rem
2020-04-01 22:42:24 +08:00
a {
padding 6px 20px
2022-10-14 17:56:32 +08:00
color var(--text-color-3)
border-radius 20px
2020-04-01 22:42:24 +08:00
&:hover {
2022-10-14 17:56:32 +08:00
color var(--text-color-2)
border 1px solid var(--text-color-3)
2020-04-01 22:42:24 +08:00
}
2020-12-01 16:51:38 +08:00
&.active {
2022-10-14 17:56:32 +08:00
color var(--text-color-2)
border 1px solid var(--text-color-3)
2020-12-01 16:51:38 +08:00
}
2020-04-01 22:42:24 +08:00
}
}
}
}
.window-mask {
position absolute
top 0
z-index $z-index-1
width 100%
height 100vh
background rgba(0, 0, 0, 0.4)
visibility hidden
opacity 0
transition-t("transform, opacity", "0, 0", "0.38, 0.38", "ease, ease")
2021-01-05 11:48:58 +08:00
.header-drawer-show & {
visibility visible
opacity 1
2020-04-01 22:42:24 +08:00
}
}
2021-01-05 11:48:58 +08:00
}
2021-01-05 11:48:58 +08:00
.header-drawer-show {
overflow hidden
2020-07-09 18:25:20 +08:00
}