Skip to content

Commit

Permalink
try to fix sticky header
Browse files Browse the repository at this point in the history
  • Loading branch information
cmahnke committed Jul 28, 2024
1 parent 4d542c7 commit 6033468
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let mql = window.matchMedia('(max-width: 35em)');
if (!mql.matches) {
/* var sticky = new Sticky('#head');*/
/* useGetBoundingClientRect: true, customVerticalPosition: true */
var sticky = stickybits('#head', { useStickyClasses: true, stuckClass: "sticky-top"});
//var sticky = stickybits('#head', { useStickyClasses: true, stuckClass: "sticky-top"});
}

if (document.querySelector('.type-text')) {
Expand Down
3 changes: 3 additions & 0 deletions assets/scss/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ a:visited {
.header {
font-family: 'League Spartan', Futura, sans-serif;
background: white;
position: sticky;
top: 0;
z-index: 100;

&.sticky-top,
&.js-is-sticky {
Expand Down
22 changes: 12 additions & 10 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@

</head>

{{- $class := "" }}
{{- with .Page.File -}}
{{- if or (hasPrefix .Path "about") (hasPrefix .Path "/about") -}}
{{- $class = "about" -}}
{{- end -}}
{{- end -}}

{{- if .Params.metaPage -}}
{{- $class = printf "%s %s" $class "meta" -}}
{{- end -}}
{{- $class := "" }}
{{- with .Page.File -}}
{{- if or (hasPrefix .Path "about") (hasPrefix .Path "/about") -}}
{{- $class = "about" -}}
{{- else -}}
{{- $class = printf "%s-%s" "section" (replace .Dir "/" "" ) -}}
{{- end -}}
{{- end -}}

{{- if .Params.metaPage -}}
{{- $class = printf "%s %s" $class "meta" -}}
{{- end -}}
<body class="{{ $class }} {{ if .IsHome }}home{{ end }}">
<a name="top"></a>
<div class="page-wrapper">
Expand Down

0 comments on commit 6033468

Please sign in to comment.