What’s the best approach to creating a div that will take the full width of the screen, no matter what resolution? I’m trying to add a ‘top’ bar and bottom ‘footer’ area with divs that have a black background and styled border that I’d create with a small image and repeat. For some reason my attempts are leading to small spaces on the top and sides of the div?
My markup is similar to:
<div id="top">
Top bar stuff
</div>
<div id="pagewrap">
All the page content
</div>
CSS
#top {
width: 100%;
margin: 0;
padding: 0;
background-color:#000
Just use
top:0;andleft: 0;and you can also eliminatepadding: 0. Don’t usetop: 0;for other div except top, useleft: 0;for other div for eliminate the left space.