Skip to content

Commit a4da61d

Browse files
committed
Navbar: fix transparent effect with !important and negative margin
Use !important to beat Docusaurus CSS. Pull section_page_top and hero_container behind the sticky navbar with margin-top: -navbarHeight so the section background shows through the transparent navbar.
1 parent 4cca65c commit a4da61d

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/components/home/Hero/styles.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
.hero_container {
1212
background-color: var(--ifm-bg-brand);
1313
padding-bottom: var(--ifm-spacing-3xl);
14+
margin-top: calc(-1 * var(--ifm-navbar-height));
1415
}
1516

1617
.hero_body {

src/components/layout/styles.module.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
}
77

88
.section_page_top {
9-
padding-top: var(--ifm-spacing-3xl);
9+
margin-top: calc(-1 * var(--ifm-navbar-height));
10+
padding-top: calc(var(--ifm-spacing-3xl) + var(--ifm-navbar-height));
1011
}
1112

1213
.section_white {
@@ -36,7 +37,7 @@
3637
}
3738

3839
.section_page_top {
39-
padding-top: var(--ifm-spacing-2xl);
40+
padding-top: calc(var(--ifm-spacing-2xl) + var(--ifm-navbar-height));
4041
}
4142
}
4243

src/css/custom.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,13 @@ a.menu__link:active {
351351
}
352352

353353
html:not([data-navbar-scrolled]) .navbar {
354-
--ifm-navbar-background-color: transparent;
355-
--ifm-navbar-shadow: none;
354+
background-color: transparent !important;
355+
box-shadow: none !important;
356356
}
357357

358358
html[data-navbar-scrolled] .navbar {
359-
--ifm-navbar-background-color: var(--ifm-bg-neutral);
360-
--ifm-navbar-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
359+
background-color: var(--ifm-bg-neutral) !important;
360+
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08) !important;
361361
}
362362

363363
/* Home page at top: white links over dark hero */

0 commit comments

Comments
 (0)