Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: On hover show and hide different div's at the same time? [duplicate]

Tags:

css

Here is CSS example how to show hidden div (on hover):

<div class="showhim">HOVER ME<div class="showme">hai</div></div>

and

.showme{ 
display: none;
}
.showhim:hover .showme{
display : block;
}

Can I show one div and hide another one at the same time by using only CSS? Here is example how to use JS for this purpose: http://jsfiddle.net/joshvito/GaZQ6/

like image 292
mbigun Avatar asked Jun 30 '13 17:06

mbigun


3 Answers

http://jsfiddle.net/MBLZx/

Here is the code

 .showme{ 
   display: none;
 }
 .showhim:hover .showme{
   display : block;
 }
 .showhim:hover .ok{
   display : none;
 }
 <div class="showhim">
     HOVER ME
     <div class="showme">hai</div>
     <div class="ok">ok</div>
</div>

   
like image 78
Bugaloo Avatar answered Oct 15 '22 22:10

Bugaloo


if the other div is sibling/child, or any combination of, of the parent yes

    .showme{ 
        display: none;
    }
    .showhim:hover .showme{
        display : block;
    }
    .showhim:hover .hideme{
        display : none;
    }
    .showhim:hover ~ .hideme2{ 
        display:none;
    }
    <div class="showhim">
        HOVER ME
        <div class="showme">hai</div> 
        <div class="hideme">bye</div>
    </div>
    <div class="hideme2">bye bye</div>
like image 36
Patrick Evans Avatar answered Oct 16 '22 00:10

Patrick Evans


Have you tried somethig like this?

.showme{display: none;}
.showhim:hover .showme{display : block;}
.hideme{display:block;}
.showhim:hover .hideme{display:none;}

<div class="showhim">HOVER ME
  <div class="showme">hai</div>
  <div class="hideme">bye</div>
</div>

I dont know any reason why it shouldn't be possible.

like image 1
Developicus Avatar answered Oct 15 '22 22:10

Developicus