css3 - Hide on :hover, DIV over DIV -


i have div on top of div.

what want achieve hide div on top able access div below.

i've tried opacity, since top div still there, transparent, won't allow me interact content of div below. i've tried display:none;, visibility: hidden; , z-index. none of work.

how achieve css3, can use transition?

html:

<li class="panel-box">      <div class="front box-style"> </div>     <div class="back"> </div>  </div> </li> 

css:

.panel-box {     margin: 5px;     padding: 0;     display: inline-block;     clear: none;     float: left;     width: 310px;     height: 200px;     position: relative; }  .box-style {     background-color: red; }  .front {     width: 310px;     height: 200px;     z-index: 5;     opacity: 0;     display: block;     position: absolute;     top: 0;     left: 0; }  .front:hover {     opacity: 0;     display: none;   }  .back {     width: 310px;     height: 200px;     background-color: rgba(57, 54, 55, 0.95);     position: absolute;     top: 0;     left: 0;     z-index: 0; } 

thanks bunch.

i've put bit of workaround seems of this, fail miserably on ie.

tested , works reasonably on chrome… ymmv :)

it uses combination of z-index , sibling selectors allow front/back divs swap places in stacking context.

i had swap places front/back use css sibling selectors. don't claim perfect example, perhaps it'll ideas flowing.

basically happening here is:

  • as mouse enters - trigger .front:hover
  • front z-index goes -1 triggering .back:hover
  • back z-index goes 100 keeping on top of stack
  • sibling selector back:hover + front keeps front opacity @ 0
  • when mouse transitions out, reverses

the reverse transition not smooth - haven't quite figured out if can fixed yet.

demo

css

.panel-box {     margin: 5px;     padding: 0;     display: inline-block;     clear: none;     float: left;     width: 310px;     height: 200px;     position: relative; }  .front {     width: 310px;     height: 200px;     padding: 10px;     z-index: 5;     opacity: 1;     display: block;     position: absolute;     background-color: red;     top: 0;     left: 0;     -webkit-transition: opacity .5s ease; }  .front:hover {     opacity: 0;     z-index: -1; }  .back {     width: 310px;     height: 200px;     padding: 10px;     color: white;     background-color: rgba(57, 54, 55, 0.95);     position: absolute;     top: 0;     left: 0;     z-index: 0;     opacity: 0;     -webkit-transition: opacity .5s ease; }  .back:hover + .front {     opacity: 0; }  .back:hover {     z-index: 100;     opacity: 1; } 

html

<li class="panel-box">     <div class="back">content goes here</div>     <div class="front box-style"></div> </li> 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -