Skip to content

Commit fd523b5

Browse files
authored
fix: Avoid layout shift when scrollbar appears (#256)
A different approach after #193 had to be reverted.
1 parent d3d27ec commit fd523b5

File tree

9 files changed

+18
-16
lines changed

9 files changed

+18
-16
lines changed

assets/sass/navigation.scss

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
#header {
1+
2+
.o-header {
23
position: sticky;
34
width: 100%;
45
top: 0;
56
box-shadow: 0 .4rem 1rem 0 rgba(0,0,0,.1);
6-
}
7-
8-
.o-header {
97
background-color: var(--bg-default);
108
z-index: 5;
11-
position: relative;
129
height: 6rem;
10+
padding-left: calc((100vw - 100%) / 2);
1311
}
1412

1513
.o-header__wrapper {

assets/sass/print.scss

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
margin-bottom: 1rem;
1515
}
1616

17-
main > .o-container.o-single,
18-
main > .o-container.o-list {
17+
main > .o-container > .o-single,
18+
main > .o-container > .o-list {
1919
margin-top: 0;
2020
}
2121

2222
.o-single__container,
23-
.o-container,
24-
main > .o-container {
23+
.o-container {
2524
padding: 0;
2625
}
2726

assets/sass/styles.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ a {
4949

5050
main {
5151
margin-top: 2rem;
52+
padding-left: calc(100vw - 100%);
5253
}
5354

5455
.o-container {
@@ -85,7 +86,7 @@ main {
8586
padding: 2rem;
8687
}
8788

88-
main > .o-container:is(.o-single--with-sidemenu) {
89+
.o-single--with-sidemenu {
8990
background-color: unset;
9091
padding: 0;
9192

layouts/_default/baseof.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
</head>
99
<body>
1010
<header id="header" class="o-header">{{ partialCached "header.html" . }}</header>
11-
<main id="content" class="o-container{{ if .IsHome }} o-startpage{{ end }}">{{ block "main" . }}{{ end }}</main>
11+
<main id="content" class="{{ if .IsHome }} o-startpage{{ end }}">
12+
<div class="o-container">
13+
{{ block "main" . }}{{ end }}
14+
</div>
15+
</main>
1216
<footer class="o-footer o-container">{{ partial "footer.html" . }}</footer>
1317
{{ if and (eq .Kind "page") (or (eq .Page.Type "country") (eq .Page.Type "operator")) }}
1418
{{ partial "snackbar" . }}

layouts/_default/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<div class="o-container o-list">
2+
<div class="o-list">
33
<div>
44
<h1 data-pagefind-meta="title">{{ .Title }}</h1>
55
{{ .Content }} {{ range .Pages }}

layouts/country/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ define "main" }}
22
{{ $related := .Site.RegularPages.RelatedIndices . "country" }}
33

4-
<article class="o-container o-single o-single--with-sidemenu">
4+
<article class="o-single o-single--with-sidemenu">
55
{{ partial "sidemenu" . }}
66
<div class="o-single__content-wrapper" data-pagefind-body>
77
<div class="o-single__container content_with_heading">

layouts/news/list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<article class="o-container o-list o-list--news">
2+
<article class="o-list o-list--news">
33
<div>
44
<h1 data-pagefind-meta="title">{{ .Title }}</h1>
55
{{ .Content }}

layouts/news/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<article class="o-container o-single o-single--with-sidemenu">
2+
<article class="o-single o-single--with-sidemenu">
33
<aside id="aside" class="o-aside">
44
{{ partial "image" (partial "helper/contentImage" . ) }}
55
<div class="o-single__container">

layouts/operator/single.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ define "main" }}
2-
<article class="o-container o-single o-single--with-sidemenu">
2+
<article class="o-single o-single--with-sidemenu">
33
{{ partial "sidemenu" . }}
44
<div class="o-single__content-wrapper" data-pagefind-body>
55
<div class="o-single__container content_with_heading">

0 commit comments

Comments
 (0)