I have been trying to add background image to a div class using css. but have no success.
HTML code:-
<header id="masthead" class="site-header" role="banner">
<div class="header-shadow"></div>
<hgroup></hgroup>
<nav role="navigation" class="site-navigation main-navigation">
</nav><!-- .site-navigation .main-navigation -->
</header><!-- #masthead .site-header -->
CSS:-
.header-shadow{
background-image: url('../images/header-shade.jpg');
}
Additional information:
This is an image with shadow and i am using it at the top of the website, so it mustn't have a particular width.
It is happening because
.header-shadow
is empty.Give
height
to it.Fiddle here.
To use an image for body background in CSS
You can try this also for setting class in div section;
Add height & width properties to your .css file.