-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Default theme nav bar background does not extend fully #4653
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It also does not fully extend to the left if the screen is over the largest breakpoint. |
Use something like .VPNav {
--vp-nav-bg-color: red;
background-color: var(--vp-nav-bg-color);
.title .VPNavBarTitle .title {
border-color: var(--vp-nav-bg-color);
}
} |
Here's a patch of how I fixed it:
diff --git a/node_modules/vitepress/dist/client/theme-default/components/VPNavBar.vue b/node_modules/vitepress/dist/client/theme-default/components/VPNavBar.vue
index d1fbe36..1edd6db 100644
--- a/node_modules/vitepress/dist/client/theme-default/components/VPNavBar.vue
+++ b/node_modules/vitepress/dist/client/theme-default/components/VPNavBar.vue
@@ -172,16 +171,22 @@ watchPostEffect(() => {
.VPNavBar.has-sidebar .content {
position: relative;
z-index: 1;
- padding-right: 32px;
padding-left: var(--vp-sidebar-width);
}
+
+ .VPNavBar.has-sidebar .content-body {
+ padding-right: 32px;
+ }
}
@media (min-width: 1440px) {
.VPNavBar.has-sidebar .content {
- padding-right: calc((100vw - var(--vp-layout-max-width)) / 2 + 32px);
padding-left: calc((100vw - var(--vp-layout-max-width)) / 2 + var(--vp-sidebar-width));
}
+
+ .VPNavBar.has-sidebar .content-body {
+ padding-right: calc((100vw - var(--vp-layout-max-width)) / 2 + 32px);
+ }
}
.content-body {
diff --git a/node_modules/vitepress/dist/client/theme-default/components/VPSidebar.vue b/node_modules/vitepress/dist/client/theme-default/components/VPSidebar.vue
index 35fa783..10ea85b 100644
--- a/node_modules/vitepress/dist/client/theme-default/components/VPSidebar.vue
+++ b/node_modules/vitepress/dist/client/theme-default/components/VPSidebar.vue
@@ -111,8 +111,8 @@ watch(
@media (min-width: 1440px) {
.VPSidebar {
- padding-left: max(32px, calc((100% - (var(--vp-layout-max-width) - 64px)) / 2));
- width: calc((100% - (var(--vp-layout-max-width) - 64px)) / 2 + var(--vp-sidebar-width) - 32px);
+ padding-left: max(32px, calc((100vw - (var(--vp-layout-max-width) - 64px)) / 2));
+ width: calc((100vw - (var(--vp-layout-max-width) - 64px)) / 2 + var(--vp-sidebar-width) - 32px);
}
}
I'm uncertain if this is the proper way to fix the issue, however if it is, I can apply the fix to source code and open a PR. |
write below css in style.css. .VPNav { :root { |
The two solutions given by @brc-dd and @takemoto61 don't quite work, they conflict with the following features in the default theme:
The patch I gave correctly preserves these features from default theme. |
Describe the bug
Using default theme, nav bar background does not extend fully to the right in widescreen mode, causing customizing with
--vp-nav-bg-color
to be unusable.Reproduction
Create a project with default theme with customized CSS:
Observe that nav bar background does not extend fully to the right in widescreen mode:

Expected behavior
Nav bar background to extend fully.
System Info
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: