Get div to view full page

Whenever I try to make a div with a width of 100%, it does not intersect the entire page, it leaves small margins on both sides (upper lower left and right), I would like the div to go through the whole page, for example, the title bar at the top parts of this page.

+4
source share
6 answers

You must set the margin and padding of the body element to 0. Like this (in CSS):

 body { margin: 0; padding: 0; } 

Also remember to set the margin of the div element to 0 .

+5
source

This is the body field from the browser field reset and indentation:

 body { margin: 0; padding: 0; } 
+3
source

Try CSS Reset:

 * { margin: 0; padding: 0; } 

It’s simple, there are thousands of more advanced ones on the Internet.

+1
source

Do you have body fields set to 0px? In the stylesheet, set body { margin:0px; } body { margin:0px; } . If you want to keep the body fields you need to adjust the width of the div. Something like div#idOfDiv { margin-left:-10px; margin-right: -10px } div#idOfDiv { margin-left:-10px; margin-right: -10px }

+1
source

Set the uppercase label to 0:

 body { padding: 0; } 
0
source

There is no need for padding, since padding is inside a div and is measured as the distance from the edge. Just set margin to 0px if you need a specific set of fields, then do it like @sho and set them separately.

0
source

Source: https://habr.com/ru/post/1389491/


All Articles