Skip to content

Commit c22b07f

Browse files
committedJun 16, 2024
html: try sticky navbar without using max-height on maing wrapper
This is done to make the content height appropriate rather than immitating that the content only takes up 100% view port height and artificially introducing a scroll. This ensures the content is a bit more accessible and should work well with any tool that relies on the height.
1 parent d435ce1 commit c22b07f

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed
 

‎css/main.css

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,27 @@ body {
2929
}
3030

3131
.site {
32-
text-align: left;
33-
padding: 2em 2em 0;
34-
float: left;
35-
-webkit-box-flex: 1;
36-
-webkit-flex: 1;
37-
-ms-flex: 1;
38-
max-width: 700px;
32+
text-align: left;
33+
padding: 2em 2em 0;
34+
flex-grow: 1;
35+
max-width: 700px;
3936
}
4037

4138
.navbar {
42-
float: left;
39+
position: -webkit-sticky; /* For Safari */
4340
position: sticky;
4441
top: 0;
45-
overflow-y: scroll;
4642
text-align: left;
4743
width: 15em;
44+
height: fit-content; /* Ensures the sidebar height adapts to its content */
45+
max-height: 100vh;
4846
padding: 2em;
4947
}
5048

5149
.navbar > ul {
5250
margin: 0;
51+
padding: 0;
5352
list-style: none;
54-
position: relative;
55-
line-height: 0;
5653
}
5754

5855
.navbar > ul > li {
@@ -64,26 +61,24 @@ body {
6461
}
6562

6663
#menuLinkBar {
67-
background-color: #a09a93;
68-
text-align: right;
69-
padding: 0.3em 2em;
70-
-webkit-box-ordinal-group: 2;
71-
-webkit-order: 1;
72-
-ms-flex-order: 1;
73-
order: 1;
74-
display: none;
64+
background-color: #a09a93;
65+
text-align: right;
66+
padding: 0.3em 2em;
67+
-webkit-box-ordinal-group: 2;
68+
-webkit-order: 1;
69+
-ms-flex-order: 1;
70+
order: 1;
71+
display: none;
7572
}
7673

7774
#wrapper {
7875
display: -webkit-box;
7976
display: -webkit-flex;
8077
display: -ms-flexbox;
8178
display: flex;
82-
margin: 0 auto;
83-
max-height: 100vh;
84-
overflow-x: hidden;
85-
overflow-y: scroll;
8679
justify-content: center;
80+
margin: 0 auto;
81+
width: 100%;
8782
}
8883

8984
@media (max-width: 700px) {

0 commit comments

Comments
 (0)