vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.22k stars 2.13k forks source link

The page width be changed when y scrollbar appears cause bad ux #4215

Closed wbxl2000 closed 2 months ago

wbxl2000 commented 2 months ago

Describe the bug

When the vertical scroll bar appears in some long content pages, the page width changes, which results in a bad user experience.

Maybe add placeholder space for the scrollbar?

https://github.com/user-attachments/assets/e43a537c-6e7c-4880-99bb-5c8ac7d39f2e

Reproduction

https://vitepress.dev/reference/default-theme-carbon-ads

compare to

https://vitepress.dev/reference/default-theme-search

Expected behavior

the content width don't be changed, which means the toc's and nav bar's position will not change.

System Info

all

Additional context

No response

Validations

wbxl2000 commented 2 months ago

Here is an article describing this.

brc-dd commented 2 months ago

Duplicate of #1054

wbxl2000 commented 2 months ago

Got it, thanks.

For others encountering this issue, I share my way to "fix" it.

/* .vitepress/theme/custom.css */
html {
    overflow-y: scroll;
}

body::-webkit-scrollbar{
  width:10px;
  height:10px;
}
body::-webkit-scrollbar-track{
  background: #fff;
  border-radius:2px;
}
body::-webkit-scrollbar-thumb{
  background: #bfbfbf;
  border-radius:10px;
}
body::-webkit-scrollbar-thumb:hover{
  background: #333;
}
body::-webkit-scrollbar-corner{
  background: #179a16;
}