You'll need to make a background img element that is positioned absolute inside a relative parent.
jsFiddle
Here is an example of what I mean.
HTML Notice I add a div with the class li-background
as first item in each li
. This will be edited by CSS to not show on load and be absolutely positioned within its li parent which is relatively positioned. I also set its z-index
to -1 so it doesnt show in from of text or any other item in li, so its a background!
<ul>
<li id="een">
<div class="li-background"><img src="http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /></div>
<h1>Title</h1>
<p id="text1">Text</p>
</li>
<li id="een">
<div class="li-background"><img src="http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /></div>
<h1>Title2</h1>
<p id="text1">Text2</p>
</li>
<li id="een">
<div class="li-background"><img src="http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /></div>
<h1>Title3</h1>
<p id="text1">Text3</p>
</li>
<li id="een">
<div class="li-background"><img src="http://www.freenew.net/upload/pscreen/47/gradient-screensaver-32.jpg" /></div>
<h1>Title4</h1>
<p id="text1">Text4</p>
</li>
</ul>
CSS
ul li { position: relative; }
ul li:hover { color: white; }
.li-background {
display: none;
height: 100%;
left: 0;
position: absolute;
top: 0;
width: 100%;
z-index: -1;
}
.li-background img {
height: 100%;
width: 100%;
}
jQ Script
$("li").hover(function(eIn) {
$(this).children(".li-background").stop().fadeIn();
},
function(eOut) {
$(this).children(".li-background").stop().fadeOut();
});