diff options
| author | Eltrac <eltrac233@gmail.com> | 2024-11-29 00:09:07 +0800 |
|---|---|---|
| committer | Eltrac <eltrac233@gmail.com> | 2024-11-29 00:09:07 +0800 |
| commit | c510e8e8d8f57803e7c9d0fb8b8bbaf8ba4f2ca6 (patch) | |
| tree | f80981cbefb9406eb5d38c78df2863a608a50c8e | |
| parent | 1a0692d23e15f80afcc0c1e9a394fa33ff125628 (diff) | |
feat(theme): nav active link style
| -rw-r--r-- | hugo.toml | 4 | ||||
| -rw-r--r-- | themes/yinyang/assets/css/index.css | 23 | ||||
| -rw-r--r-- | themes/yinyang/layouts/partials/header.html | 4 |
3 files changed, 23 insertions, 8 deletions
@@ -22,12 +22,12 @@ favicon = "/favicon.png" [[params.nav]] name = "关于" -link = "/about" +link = "/about/" target = "_self" [[params.nav]] name = "链接" -link = "/links" +link = "/links/" target = "_self" [[params.nav]] diff --git a/themes/yinyang/assets/css/index.css b/themes/yinyang/assets/css/index.css index aabbd648..46e9fea4 100644 --- a/themes/yinyang/assets/css/index.css +++ b/themes/yinyang/assets/css/index.css @@ -155,18 +155,33 @@ a:hover { display: flex; justify-content: center; align-items: center; - background-color: var(--text-color); width: fit-content; - padding: 0.25rem 0.75rem; border-radius: 1rem; + overflow: hidden; } .header-item a { + display: inline-block; color: var(--background-color); + padding: 0.25rem 0.5rem; + background-color: var(--text-color); +} + +.header-item:first-child a { + padding-left: 0.75rem +} + +.header-item:last-child a { + padding-right: 0.75rem } -.header-item { - margin: 0 5px; +.header-item.active a { + color: var(--text-color); + background-color: var(--block-background-color); +} + +.header-item a:hover { + text-decoration: none; } .header-line { diff --git a/themes/yinyang/layouts/partials/header.html b/themes/yinyang/layouts/partials/header.html index c176b880..b1f6e50e 100644 --- a/themes/yinyang/layouts/partials/header.html +++ b/themes/yinyang/layouts/partials/header.html @@ -10,8 +10,8 @@ <!-- Navigation --> <nav class="header-items"> {{ range .Site.Params.nav }} - <div class="header-item"> + <div class="header-item {{ if eq .link $.Page.RelPermalink }}active{{ end }}"> <a href="{{ .link }}" target="{{ .target }}">{{ .name }}</a> </div> {{ end }} -</nav>
\ No newline at end of file +</nav> |
