I have two images side-by-side. When the user hovers over an image, it should expand.
HTML:
<a href="#"><div id="skinny"></div></a>
<a href="#"><div id="room9"></div></a>
jQuery:
$('#skinny').hover(function() {
$(this).animate({width: '220px'}, 'fast');
$('#room9').animate({width: '80px'}, 'fast');
}, function() {
$(this).animate({width:'150px'},'fast');
$('#room9').animate({width: '150px'}, 'fast');
});
jsFiddle: http://jsfiddle.net/G4q4q/
It “works” with the left image, but I couldn’t get it to work with the right. My current method is inefficient, so if you have any suggestions to optimize it, please let me know.
Ok, well I’ve made a very crude example that doesn’t allow for expansion/multiple images, but you should get the idea. To
clipelements in CSS, just justoverflow: hiddenjsFiddle: http://jsfiddle.net/G4q4q/10/
HTML
CSS
Javascript
Edit notes: I edited this to make it a little better than my first attempt.