0

I am trying to get a div to show on hover using the "+" combinater and it's not working. Here is my code:

HTML

<div class="about-team">
<div class="client">
    <div class="about-team-left">   <a href="#"><img src="http://placehold.it/150x150"></a>

    </div>
    <div class="about-team-right">
        <p>Just writing a quick note to tell you how very happy we are with our new addition to our family... Our "Molly" is such an adorable puppy... <a id="rm">READ MORE</a>
        </p>
    </div>
    <div class="readmore1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, qui est quo consequuntur esse iure tempora. Hic tenetur nemo repudiandae quae unde sed aliquid deleniti ad! Facilis, reprehenderit culpa mollitia.</div>

CSS

.readmore1 {
display: none;
}

#rm:hover + .readmore1 {
display: block;
height: 100px;
width: 200px;
}

JSfiddle:

http://jsfiddle.net/9zDEp/3/

Thanks!

YKB
  • 21
  • 9

2 Answers2

0

You need to change markup to show them as adjacent selectors like

<div class="about-team-right">Just writing a quick note to tell you how very happy we are with our new addition to our family... Our "Molly" is such an adorable puppy... </div>
   <a id="rm">READ MORE</a>
   <div class="readmore1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, qui est quo consequuntur esse iure tempora. Hic tenetur nemo repudiandae quae unde sed aliquid deleniti ad! Facilis, reprehenderit culpa mollitia.</div>
</div>

What does the “+” (plus sign) CSS selector mean?

JSFiddle


Here is an fiddle another approach using Javascript

Community
  • 1
  • 1
Praveen
  • 55,303
  • 33
  • 133
  • 164
0

Your html structure didn't work with the anchor and div inside the p but you can switch the text to be inside a span so they wrap:

<div class="about-team">
<div class="client">
    <div class="about-team-left"> <a href="#">
        <img src="http://placehold.it/150x150" /></a>

    </div>
    <div class="about-team-right"> 
        <span>Just writing a quick note to tell you how very happy we are with our new addition to our family... Our "Molly" is such an adorable puppy...</span>  
        <a id="rm">READ MORE</a>

        <div class="readmore">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur, qui est quo consequuntur esse iure tempora. Hic tenetur nemo repudiandae quae unde sed aliquid deleniti ad! Facilis, reprehenderit culpa mollitia.</div>
    </div>
</div>

Also, I would consider using a more generalized CSS that doesn't rely on ID fields, like this:

.readmore {
display: none;
}

a:hover + div.readmore {
display: block;
height: 100px;
width: 200px;
}  

http://jsfiddle.net/9zDEp/15/

AtlasRider
  • 76
  • 1
  • 7
  • I noticed that you and the other response both removed the

    tag. I noticed that if I just put

    inside the

    after the READ MORE it will not work...

    – YKB Feb 01 '14 at 19:08
  • It looks like the nesting of a div in a p tag is invalid according to HTML standards. Violating this rule, may be why the expected hover did not work. See http://stackoverflow.com/a/4291608/904713 for more details. – AtlasRider Feb 02 '14 at 18:55