I have a background image that I want to show in a div floated right.
Here is the css
<style>
.myclass {
background-image: url('images/myimage.png') no-repeat 0 0;
float:right;
background-size:80px 80px;
}
</style>
Then I have a list:
<ul>
<li>
<div class="myclass"> </div>
<p>Hello</p>
</li>
</ul>
For some reason the image is not showing at all.
You’re using the
background-imageselector but using it as if it were the shorthandbackgroundrule.Use:
background: url('images/myimage.png') no-repeat 0 0;You’ll also need to specify a width and height to the div as the float collapses it and the
will only give it a marginal height and width.jsFiddle example