Reputation: 123
I have some nested div and in one i got an image. If the user hovers the image it should display another span (in the same wrapper).
html source:
<div class="columns one-third">
<a href="#">
<img src="http://fc02.deviantart.net/fs70/i/2013/088/7/2/transformers_gold_icon_by_slamiticon-d5z7dqs.png" alt="Jack Sparrow" width="250px">
</a>
<div class="team-name"><h5>Jack Sparrow</h5><span></span></div>
<div class="team-about"><p><span class="slug">Chief Executive Officer / CEO</span><span class="number">#97</span></p></div>
css source:
div>a>img {
filter: url(/filters.svg#grayscale); /* Firefox 3.5+ */
filter: gray; /* IE6-9 */
-webkit-filter: grayscale(1); /* Google Chrome, Safari 6+ & Opera 15+ */
}
div>a>img:hover {
filter: none;
-webkit-filter: grayscale(0);
display:block;
}
div.team-about .slug{
float:left;
}
div.team-about .number{
float:right;
margin: -10px 10px auto;
font-size: 28px;
display: none;
}
I prepared a jsfiddle to test: http://jsfiddle.net/mnx8agy0/
hovering the image it should load the number span.
Any idea on that?
Upvotes: 4
Views: 303
Reputation: 1519
.team-about{display:none;}
div > a:hover + .team-about{display:block;}
It's quite easy to use JavaScript instead.
Upvotes: -1
Reputation: 28437
You can achieve this with the general sibling selector ~
.
http://jsfiddle.net/mnx8agy0/1/
div > a:hover ~ .team-about .number {display:block;}
Upvotes: 5
Reputation: 11305
You need to add the hover to the container div:
div.one-third:hover span {
display: block;
}
Upvotes: 0