Is there a way to program an mouseover image that controls 2 divs [larger image AND a text description]
-
18-09-2019 - |
Question
the design calls for an image gallery with thumbnails for different characters and when u roll over a thumbnail a larger version of the image appears and in a div to the left with a header and description for each character also appears.
1) is there a way to have a rollover control both divs? (enlarged image and description)
and
2) how would i need to go about syncing this up with a cms?
thank you for reading :)
Solution
Try this for a start, not sure what cms you're using etc so nfi how to answer that part:
HTML:
<a class="info" href="" onclick="return false;">
<img src="thumb.jpg"/>
<span><img src="large.jpg" /><br />
description goes here</span>
</a>
CSS:
a.info {z-index:24; position:relative; color:#999; font-size:11px; text-transform:none; font-weight:normal; text-decoration:none; border:1px solid #999; padding-left:3px; padding-right:3px; margin:5px;}
a.info:hover {z-index:25; text-decoration:none; color:#333; border-color:#333;}
a.info span {display:none; position:absolute; top:15px; left:15px; width:240px; color:#000; font-size:12px; background-color:#fff; padding:2px; border:1px solid #333;}
a.info:hover span {display:block;}
OTHER TIPS
Yes, store information about the character in the id tag of the trigger element. Like say it is mickey mouse, id="mickey" maybe you are using prototype...
$$('.trigger').each(function (el) {el.observe('mouseover',showInfo.bind(el);});
Then the function showInfo shows the divs that have the larger image and info
function showInfo(ev) {
// this refers to the element that has the mouse over, which has the descriptive id
var infoContainerId = this.id+"_info";
var imageContainerId = this.id+"_image";
$(infoContainerId).show(); // showing the div id="mickey_info"
$(imageContainerId).show(); // showing the div id="mickey_image"
}
Well.. just an example...
Using jQuery, this is untested but it would be something like this:
$('#myImageThumbnail').mouseenter(function(){
//Set the description text
$('#descriptionDiv').html('Insert character description here');
//Enlarge the image
$('#myImageThumbnail').attr('height','300');
$('#myImageThumbnail').attr('width','200');
});
$('#myImageThumbnail').mouseleave(function(){
//Remove the description text
$('#descriptionDiv').html('');
//Return image/thumbnail to original size
$('#myImageThumbnail').attr('height','150');
$('#myImageThumbnail').attr('width','100');
});
If you needed to pull dynamic info from a database for the description, simply look at the jQuery $.ajax function and set the description HTML to the returned value.