html - Change opacity of both hovered div and another div when hovering -
html - Change opacity of both hovered div and another div when hovering -
i have 2 divs have alter opacity @ same time, have work togehter. both divs have specific form because transformed skew() , absolute positioned on image. means cannot wrap 2 divs top-div.
      class="snippet-code-css lang-css prettyprint-override">#top {      background-color: red;      width: 200px;  }  #left {      width: 200px;      opacity: 0;  }  #right {      text-align: right;      width: 200px;      opacity: 0;  }        #left:hover,  #left:hover ~ #right,  #right:hover,  #top:nth-child(1):hover > #left {      background-color: rgba(0, 150, 150, 0.4);      opacity: 1;  }     class="snippet-code-html lang-html prettyprint-override"><div id="top">      <div id="left">left</div>      <div id="right">right</div>  </div>       
now question: when i'm hovering on first div it's opacity changes , opacity of sec div changes @ same time. far good. when hover on sec div it's opacity changes not opacity of first div. in snippet above works fine not in ide?!
i think problem #top:nth-child(1):hover > #left not work properly. i'm wondering why works in snippet not in ide?!
in ide happens:
      class="snippet-code-css lang-css prettyprint-override">#top {      background-color: red;      width: 200px;  }  #left {      width: 200px;      opacity: 0;  }  #right {      text-align: right;      width: 200px;      opacity: 0;  }        #left:hover,  #left:hover ~ #right,  #right:hover,  #right:hover ~ #left {      background-color: rgba(0, 150, 150, 0.4);      opacity: 1;  }     class="snippet-code-html lang-html prettyprint-override"><div id="top">      <div id="left">left</div>      <div id="right">right</div>  </div>       
i'm still waiting css solution help myself using jquery:
$(document).ready(function() {   $('#right').hover(function() {      $('#left').css({'background-color': 'rgba(0, 150, 150, 0.4)',                     'opacity': '1'});   }, function(){     $('#left').css({'background-color': '',                     'opacity': ''});   }); });    jsfiddle demo
 html css hover opacity 
 
  
Comments
Post a Comment