Skip to content

Commit

Permalink
fix(theme): avoid layout shift caused by scrollbar
Browse files Browse the repository at this point in the history
fixes #1054
  • Loading branch information
zqianem committed Mar 16, 2023
1 parent 1f2f1ff commit e8587e8
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/client/theme-default/components/VPContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const { hasSidebar } = useSidebar()
id="VPContent"
:class="{
'has-sidebar': hasSidebar,
'is-home': frontmatter.layout === 'home'
}"
>
<slot name="not-found" v-if="page.isNotFound"><NotFound /></slot>
Expand Down Expand Up @@ -55,15 +54,16 @@ const { hasSidebar } = useSidebar()
width: 100%;
}
.VPContent.is-home {
width: 100%;
max-width: 100%;
}
.VPContent.has-sidebar {
margin: 0;
}
@media (min-width: 768px) {
.VPContent {
width: 100vw;
}
}
@media (min-width: 960px) {
.VPContent {
padding-top: var(--vp-nav-height);
Expand Down
1 change: 1 addition & 0 deletions src/client/theme-default/components/VPFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const { hasSidebar } = useSidebar()
@media (min-width: 768px) {
.VPFooter {
width: 100vw;
padding: 32px;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/client/theme-default/components/VPLocalNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const { hasSidebar } = useSidebar()
}
@media (min-width: 768px) {
.VPLocalNav {
width: 100vw;
}
.menu {
padding: 0 32px;
}
Expand Down
6 changes: 6 additions & 0 deletions src/client/theme-default/components/VPNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ provide('close-screen', closeScreen)
transition: background-color 0.5s;
}
@media (min-width: 768px) {
.VPNav {
width: 100vw;
}
}
@media (min-width: 960px) {
.VPNav {
position: fixed;
Expand Down
4 changes: 2 additions & 2 deletions src/client/theme-default/components/VPSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ watchPostEffect(async () => {
@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);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/client/theme-default/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ body {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
overflow-x: hidden;
}

main {
Expand Down

0 comments on commit e8587e8

Please sign in to comment.