Vertical scrollbar takes up right margin; using right padding avoids vertical scrollbar doing that

In my blogbook HTML, I faced a problem of vertical scrollbar taking up significant (almost whole, in some cases) part of the right margin of 20px that I had specified. The solution is to use right padding instead. Related CSS code with comments is given below:

  padding-left: 20px;
  padding-right: 20px;
  /* Margin-right gets covered by vertical scrollbar
  Padding is a better solution
  Ref: https://www.reddit.com/r/Frontend/comments/scafy2/why_is_the_scroll_bar_covering_my_right_margin/ */
  /* margin-left: 20px;
  margin-right: 20px; */

Comments

Archive