Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

100% DIV width is not really 100%

When I have a <div> with width: 100%, it is not really 100%:

<div id="div">testtesttesttesttest</div>  ...  #div {   width: 100%;   background-color: red; } 

Now when you resize the window, so there is a horizontal scrollbar, and you scroll to the right, then the background is vanished. How can I remain the background in this case?

Here you can see the problem in action: http://beta.ovoweb.net/?i=3

Now when you resize the window and scroll to the right, you can't see the background anymore. How to fix this?

like image 501
www.data-blogger.com Avatar asked Jun 14 '11 13:06

www.data-blogger.com


People also ask

Why div is not full width?

There is probably padding on the containing div or body tag.

Is width 100 and width 100%?

Answer is No. cause 100 is pixels and 100% is percentage of overall size of page.

Does width 100% include padding?

No, element width does not include padding, margin, or border.

What does width 100% means in CSS?

if you specify width:100%, the element's total width will be 100% of its containing block plus any horizontal margin, padding and border.


1 Answers

The 100% value is 100% of the parent's width or the view port. See the documentation.

like image 85
James Sumners Avatar answered Oct 09 '22 11:10

James Sumners