Img Hovering
Simple Img hover for the index.html
by Aleshanee
HTML
<body>
<div id='wrapper'>
<h1>Just a simple Test Site</h1>
<br/>
<div id='hoverZone1'>
<img id='hoverMe' src="//img5.fotos-hochladen.net/uploads/duck7gahy0nebj.jpg" />
</div>
<div id='hoverZone2'>
<img id="hoverMe2" src="//img5.fotos-hochladen.net/uploads/cow0hoyupx8vq.jpg"/>
</div>
</div>
</body>
CSS
* {
margin: 0;
padding: 0;
}
body {
text-align: center; /* IE */
background-color: #F0F0F0;
}
#wrapper {
width: 960px;
margin: 0 auto;
text-align: left;
margin-top: 25px;
background-color: #F0F0F0;
}
#hoverMe {/*DUCK*/
position: absolute;
width: auto;
height: auto;
clip: rect(auto, 270px, auto, auto);
z-index: 4;
}
#hoverZone1 {
position: relative;
width: 270px;
height: 409px;
/*z-index: 3;*/
/*background-color: yellow;*/
}
#hoverMe2 {/*COW*/
position: absolute;
clip: rect(auto, auto, auto, 270px);
width: auto;
height: auto;
margin-left: -270px;
z-index: 3;
}
#hoverZone2 {
position: relative;
width: 296px;
height: 409px;
/*background-color: brown;*/
margin-top: -409px;
margin-left: 270px;
/*z-index: 2;*/
}
JavaScript
$(document).ready(function() {
//_____DUCK______Mouseenter_______________________________________________
$('#hoverZone1').bind('mouseenter',function() {
$('#hoverMe').css('z-index','4');
$('#hoverMe2').css('z-index','3');
$('#hoverZone1').css('z-index', '2');
$('#hoverZone2').css('z-index', '1');
$('#hoverMe2').stop().fadeTo('slow', 0.5);
$('#hoverMe').stop().animate({
fontSize : 680
}, {
duration : 1000,
step : function(now, fx) {
$('#hoverMe').css('clip', 'rect(auto, ' + now + 'px, auto, auto)');
}
});
$('#hoverZone1').css({'width':'566px','left': '0px'});
});
// ______DUCK_______Mouseleave________________
$('#hoverZone1').bind('mouseleave',function() {
$('#hoverMe').stop().animate({
fontSize : 270
}, {
duration : 1000,
step : function(now, fx) {
$('#hoverMe').css('clip', 'rect(auto, ' + now + 'px, auto, auto)');
$('#hoverZone1').css('width', '270px');
}
});
$('#hoverMe2').fadeTo(500, 1);
});
// _____COW_______Mouseenter__________________________________________________
$('#hoverZone2').bind('mouseenter',function() {
$('#hoverMe').css('z-index','3');
$('#hoverMe2').css('z-index','4');
$('#hoverZone1').css('z-index', '1');
$('#hoverZone2').css('z-index', '2');
$('#hoverMe').stop().fadeTo('slow', 0.5);
// $('#hoverMe').css('z-index', '2');
$('#hoverMe2').stop().animate({
fontSize : -566
}, {
duration : 1000,
step : function(now, fx) {
$('#hoverMe2').css('clip', 'rect(auto, auto, auto, ' + now + 'px)');
$('#hoverZone2').css({'width': '566px', 'left': '-270px'});
$('#hoverMe2').css({'left':'270px'});
}
});
});
// _______COW________Mouseleave_______
$('#hoverZone2').bind('mouseleave',function(){
$('#hoverMe2').stop().animate({
fontSize : 270
}, {
duration : 1000,
step : function(now, fx) {
$('#hoverMe2').css('clip', 'rect(auto, auto, auto, ' + now + 'px)');
$('#hoverZone2').css({'width': '296px','left':...