0

I want a new <div> to appear on thumbnail hover.

You can inspect my code on http://techgeek.lt/naudinga/

This works:

 #main:hover  .whitewrapper {
  display: block;
}

but it hovers on #main.

I already tried (and no luck):

img.thumbnail:hover  .whitewrapper {
  display: block;
}

#main img.thumbnail:hover  .whitewrapper {
  display: block;
}

.thumbnail:hover  .whitewrapper {
  display: block;
}

img.thumbnail:hover  .whitewrapper {
  display: block;
}

img.thumbnail .alignleft:hover  .whitewrapper {
  display: block;
}

.thumbnail .alignleft:hover  .whitewrapper {
  display: block;
}

#main.thumbnail .alignleft:hover  .whitewrapper {
  display: block;
}

#main.thumbnail .alignleft img:hover  .whitewrapper {
  display: block;
}

.thumbnail .alignleft img:hover  .whitewrapper {
  display: block;
}

.thumbnail img:hover  .whitewrapper {
  display: block;
5
  • You sure tried a lot of stuff! Commented Aug 19, 2011 at 19:20
  • @Lokys: "Please fix all my code" is generally not an acceptable "question" on this site - see the FAQ. Please narrow down and clarify. But for starters - fix your <script> tags - they all give 404s. Commented Aug 19, 2011 at 19:21
  • Gustav, what do you mean by "fix script tags"? It seems like they work fine for me.. Commented Aug 19, 2011 at 19:25
  • Here's one dead script tag and there's a bunch more. Also, you need to "include" jQuery before the plugins. And you seem to have curly quotes inside the <link rel="image_src"... element. Commented Aug 19, 2011 at 21:51
  • 1
    Your entire page is also missing the closing </body> and </html> tags. I've never seen the W3C Validator choke on a page before... no doubt from the symbols (curly quotes?) on line 4. Commented Aug 19, 2011 at 21:59

2 Answers 2

1

This works:

.post-more a:first-child:hover ~ .whitewrapper, .whitewrapper:hover {
    display: block;
}

Both :first-child and the general sibling combinator (~) are supported in IE7+ and all modern browsers.


You need to fix that first a in each post:

<div class="post-more"> 
    <a href=".." onclick=".."<a title=".." href=".." >..</a></a>

that's broken HTML, which causes the selector I've provided to fail in some browsers.

Sign up to request clarification or add additional context in comments.

2 Comments

Note that I've updated my answer since I first posted it. Grab the newer version of the selector, it solves an issue with Firefox.
Thanks again! I would love to have such css skills in the future.
1

You may be able to use the + selector type.

If the div comes directly after the img, this should work:

img.thumbnail:hover + .whitewrapper {
   display: block;
}

Update: I tested it and it works for me. Here's the jsfiddle.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.