![]() |
Text Appears in Sidebar When Viewing Image on Hover
I'm currently working on a school project to build a simple web site using HTML and CSS only. I plan on using a simple gallery to showcase some photos and am using the same code (slightly modified) from this web site.
http://www.dynamicdrive.com/style/cs...image-gallery/ The changes I made are getting rid of the <br /> in the thumbnail area so they show in one row and the text and borders underneath the regular size images when the mouse hovers over the thumbnail. However, I would like for text to appear in a sidebar (seperate block element) when the user hovers over the image. In other words, when the user hovers over one image, one set of text appears but when they hover over another image, a different set of text appears. Is this possible using HTML and CSS only? |
I am affraid not!
Css can alter the appearance of the hovered element and or it's child element. It cannot alter the apperance nor content of outside elements For this you will need a bit of javascript like: Code:
onmouseover="document.getElementById('TextBox').innerHTML='Newtext' return true"Code:
onmuseout="document.getElementById('TextBox').innerHTML='' return true" |
Yes it can be done. You need to work a little on this but it should do what you want.
From The CSS Guru (Drum roll) - http://meyerweb.com/eric/css/edge/popups/demo.html |
Quote:
It is way to make text appear, but not the way OP wanted it to happen. I will try to explain: The OP way: Code:
<div id="mainContainer">The Demo way: Code:
<div id="mainContainer">As you can see, it requires a different, and larger, tree structure where you have 3 <div class="text">s instead of 1. If OP wants to change it to the Demo way, make sure that each .pictureContainer exactly fits its contained image, and that the <div class="text">s are position:absolute Maybe it will fulfil your requirements, though it is not what you asked for. |
I did say "You need to work a little on this". because I wasn't gonna. Since it depends on hover and not onclick, my mind tells me it can be done with css and html and if I was doing it, I'd give it a shot.
|
their both right. Although realistically, the only good way to do this is with javascript
|
Quote:
But to use the demo way, OP have to use a different document structure than originally planned. Quote:
If you can avoid using javascript, as you can do here, it is best to do it. The CSS way will work even if the user have javascript disabled, (which many users have). If there was anything in the document that required javascript, then you can just as well use javascript for this purpose. But there isn't, and then there is no reason to make javascript:enabled a requirement |
| All times are GMT +1. The time now is 12:29 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.