Whenever i try to make a div with width 100%, it does not go across the whole page, it leaves small margins on either side(top bottom left and right), i would like the div to go across the whole page, such as the header bar on the top of this page.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
- Adding a timeout to a render function in ReactJS
There is no need for padding as the padding is on the inside of the div and is measured as a distance from edge. Just set margin to 0px if you want a specific margin set then do it like @sho suggested and set them individually.
You have to set margin and padding of
body
element to 0. Like this (in CSS):And also remember about setting
margin
ofdiv
element to0
.This is a body margin from the browser reset margin and padding:
Set the padding to 0 for the body tag:
Try a CSS Reset:
That's a simple ones, there are thousands of more advanced ones across the web.
Do you have the body margins set to 0px? In your stylesheet set
body { margin:0px; }
. If you want to keep the body margins, you need to adjust the width of the div. Something likediv#idOfDiv { margin-left:-10px; margin-right: -10px }