Khaled Khaled - 1 month ago 6
CSS Question

CSS background-color Issue

I just have a header div into this div there is a navbar and after that there is some content i just gave that header div a background color but that background doesn't cover the hole screen width i just wanna that background cover the hole screen width but there is white space in the left,top and right
and here is the html code :

<!--Start header section-->
<div class="header">
<div class="container">
<div class="top-nav">
<h1>Apptastico</h1>
<ul>
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Work</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="content">
<img src="photos/iPhone.jpg" alt="">
<div class="web-design">
<h1>We design iOS apps</h1>
<h4>Ut In Nulla Enim. Phasellus Molestie Magna Non Est Bibendum Non Venenatis ut In Nulla Enim. Phasellus Molestie.</h4>
<p>Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu
tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim.
Phasellus molestie tempor. Suspendisse dictum feugiat.
</p>
<input type="submit" value="Request qoute">
</div>
</div>
</div>
</div>
<!--End header section-->


and here is css code

.header{
background-color: #4b5a65;
height: 505px;
overflow: hidden;
padding-top: 10px;
}


and that's the result which appear in the browser screen:
enter image description here

Answer

apply

body{
  margin:auto;
}

See snippet below

.header{
    background-color: #4b5a65;
    height: 505px;
    overflow: hidden;
    padding-top: 10px;
}
body{
  margin:auto;
}
<!--Start header section-->
<div class="header">
   <div class="container">
    <div class="top-nav">
        <h1>Apptastico</h1>
        <ul>
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Work</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </div>
    <div class="content">
        <img src="photos/iPhone.jpg" alt="">
        <div class="web-design">
            <h1>We design iOS apps</h1>
            <h4>Ut In Nulla Enim. Phasellus Molestie Magna Non Est Bibendum Non Venenatis ut In Nulla Enim. Phasellus Molestie.</h4>
            <p>Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu 
            tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim.
             Phasellus molestie tempor. Suspendisse dictum feugiat.
             </p>
            <input type="submit" value="Request qoute">
        </div>
    </div>
</div>
</div>
<!--End header section-->