0

I set up a very simple webpage using css and html and I get an unwanted vertical scrollbar. I do not get why the scrollbar appears. When I inspect my Webpage with DevTools in Fullscreen (Google Chrome) my body has a height of 1080px (my exact Monitor height) and the Div also has a height of 1080px so I see no need for the scrollbar but it is still there. I know that I can fix the problem with overflow: hidden ,but I want to know why the scrollbar appears in the first place.

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0"> 

<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<link rel="stylesheet" href="styles.css">

<title>Frontend Mentor | Interactive card details form</title>

</head>
<body>
  <div class="left bgbox"></div>
  <div class="right bgbox"></div>
</body>
</html>

CSS

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
}
body {
  height: 100vh;
}
.box {
  display: inline-block;
  height: 100%;
  margin: 0;
  padding: 0;
  width: 30%;

} I also made a Codepen : https://codepen.io/theknax-dev/pen/MWGYpxJ

TheKnax
  • 43
  • 4
  • vertical-align:top to the inline-block element – Temani Afif Sep 04 '22 at 21:09
  • The reason is the `display:inline-block` which browser default usually adds a minor 0.25em margin. More or less. So you can set it to `display:block`. Possible also to just `overflow: hidden` to the body as a workaround. – IT goldman Sep 04 '22 at 21:19

0 Answers0