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 Jan 26, 2023
1 parent c35a1f0 commit 6656584
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 @@ -20,7 +20,6 @@ const NotFound = inject('NotFound')
id="VPContent"
:class="{
'has-sidebar': hasSidebar,
'is-home': frontmatter.layout === 'home'
}"
>
<NotFound v-if="route.component === NotFound" />
Expand Down Expand Up @@ -58,15 +57,16 @@ const NotFound = inject('NotFound')
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 @@ -79,6 +79,10 @@ function scrollToTop() {
}
@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 6656584

Please sign in to comment.