Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Body/HTML elements shrink to be much smaller than viewport

I'm in the process of making my wordpress website responsive. I have two images on the page I'm working on which I want to set a max-width on of 100% to make them responsive (this is what I did on another website I made and it worked beautifully). However, I have noticed that as I shrink the page in Chrome dev tools the <html> and <body> elements are shrinking to really odd sizes, completely unrelated to the viewport size. Below are screenshots of the and elements, respectively, being hovered over in chrome dev tools:

html body

And, of course since max-width with a percentage value, "Defines the maximum width of the containing block" and the containing blocks here (<html> and body) are resizing themselves in this unusual way, when I set the images to max-width: 100% they base that off the weird size of those elements.

The only CSS I have on these elements is:

* {
  box-sizing: border-box;
}


body {
  margin: 0;
}

So my question is, where on earth are the <html> and <body> elements getting their size from?

like image 847
Maxine Ellah Avatar asked Oct 28 '25 19:10

Maxine Ellah


1 Answers

html, body{
  margin: 0; padding: 0; width: 100%;
  height: 100%;
  overflow-x: hidden !important;
}
like image 100
Movie time Avatar answered Oct 30 '25 08:10

Movie time



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!