Reputation: 23
I want to add a background image to a CSS class but it dosn't show up.
I've already tried to add height and width.
<div class="landing1">
<h2>The Lnad OF Programming</h2>
<p>get involved</p>
</div>
<style>
body,
html {
margin: 0;
size: 100%;
}
.landing1 {
margin: 3px;
text-align: center;
background-image: url(imgs/bg.jpg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
width: 400px;
height: 500px;
}
</style>
the background image isn't show up.
Upvotes: 0
Views: 220
Reputation: 12152
It is working. You are giving the image path wrong
body , html{
margin:0;
size:100%;
}
.landing1{
margin:3px;
text-align:center;
background-image:url(http://placekitten.com/500/500);
background-repeat: no-repeat;
background-size: cover;
background-position:center;
width:400px;
height:500px;
}
<div class="landing1">
<h2>The Lnad OF Programming</h2>
<p>get involved</p>
</div>
Upvotes: 1