I'm having issues coding a background image as the main background. I can't get it to center or cover the entire page even though I did coding for it. My header is a background image and is nested with the logo. I can't seem to get the header to sit over the background image so that it's directly underneath it and there are no white spaces. Not sure what to do, any help is appreciated.
Question
hbjr7
Hi,
I'm having issues coding a background image as the main background. I can't get it to center or cover the entire page even though I did coding for it. My header is a background image and is nested with the logo. I can't seem to get the header to sit over the background image so that it's directly underneath it and there are no white spaces. Not sure what to do, any help is appreciated.
HTML
</head>
<body>
<!--Header Section -->
<div class="container">
<header class="col-medium-4">
<h1><a href="index.html"><img src= "css/images/llama-logo.png" alt="logo" ></a>
</h1>
</header>
<!-- Navigation area -->
<nav>
<ul>
<li><a href="index.html">About</a></li>
<li><a href="#">Events</a></li>
<li><a href="#">Classes</a></li>
<li><a href="#">Llamas</a></li>
<li><a href="#">Shop</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
<div style="background-image"><img src="css/images/yarnbackground.png">
</div>
<div id="footer">Copyright ©2016 Leaping Llama Farm</div>
</body>
</html>
CSS
/***** MD (Medium) - Medium Desktop Size AND ABOVE! (992px) */
@media (min-width: 992px) {
h1 {
background-image: url(images/llama-logo.png);
background-position: left;
background-repeat: no-repeat;
margin-left: auto;
padding: 125px 0;
}
header{
background-image: url(images/llama-header.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: auto;
padding-top: 20px;
}
/* Nav Styles */
nav {
background-color: #00ff99;
height: 50px;
padding: 20px;
margin-top: 50px;
margin-bottom: 50px;
}
nav li {
float: left;
font-size: 25px;
margin-left: 95px;
font-family: 'Myriad', sans-serif;
font-weight: 700;
margin-top: 12px;
}
nav ul {
list-style: none;
text-align: center;
padding-bottom: 30px;
text-decoration: none;
}
nav a {
color: darkslategrey;
text-decoration: none;
}
nav a:hover {
color: white;
}
#background-image {
background: url(images/yarnbackground.png)
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
#footer {
background: orange;
height: 50px;
width: auto;
} /***** END MD (Medium) */
Link to comment
https://www.neowin.net/forum/topic/1294512-background-image/Share on other sites
2 answers to this question
Recommended Posts