![]() |
Have <p> display on image hover
I may be missing something glaringly easy, but for some reason I cannot get my text to display when I hover over an image.
HTML Code:
<div id="footer"> Code:
#footer { |
I like to use JavaScript to tell the browser that when I mouse over the photo I would like to unhide the text. Here is what I would code:
HTML: <div id="footer-left"> <a href="#"><img src="images/arrow.png" id="myimage" /></a> </div> <p id="showme">Top</p> JAVASCRIPT: var image = document.getElementById('myimage'); var show = document.getElementById('showme'); image.onmouseover = function(){ show.style.display = "block"; }; image.onmouseout = function(){ show.style.display = "none"; }; |
Quote:
|
Quote:
|
Hmmm...I doubled checked and from what I can tell there is no way to do what you wanna do using CSS only. In order for CSS to do what you are wanting it to do one selector would need to be able to tell another selector what to do, and I'm pretty sure CSS doesn't work that way. However, JavaScript and/or JQuery can do what you are asking for.
|
The only way other than JavaScript is:
Code:
#footer-left:hover + p { |
<a href="#"><img src="images/arrow.png" /></a>
CSS code: Quote:
Quote:
|
Quote:
Sweet! That does work. You will only need to add the following code to your .css file: Code:
#footer-left:hover + p { |
Quote:
|
Hi, another way of doing the same thing, and minimising coding would be to add the title tag
Code:
<a href="#"><img src="images/arrow.png" title="Top" /></a> |
Quote:
|
Hi, if you give an image a title then the title text is shown when you hover over the image. Jim
|
Solved- have <p> display on image hover
Quote:
|
Right enough, I misunderstood what you required to do. Always tend to go for simplest answer myself. Happy you got what you required. Jim
|
| All times are GMT +1. The time now is 10:50 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.