html - hover is not working on child element -
html - hover is not working on child element -
i have div within div below
<div id="locations"> <div id="h-dragbar"></div> </div>
and css below
#locations { height: 50px; width: 100%; position: relative; z-index: -1; } #h-dragbar{ background-color:black; width:100%; height: 3px; position: absolute; cursor: row-resize; bottom: 0; z-index: 999; } #h-dragbar:hover{ background-color:blue; }
but hover on div id h-dragbar not working. can test code here demo.
what doing wrong? in advance.
in new illustration jsfiddle you've provided, you're setting z-index
of -1
parent div i.e. #locations
why you're unable perform hover function on kid div i.e. #h-dragbar
. need remove negative z-index
on #locations
, it'll work fine.
update:
i've checked latest fiddle , instead of using negative z-index
#locations
in order give priority #v-dragbar
, can accomplish same using high z-index
#v-dragbar
, e.g. z-index: 9999
, , relatively smaller z-index
#locations
, e.g. z-index: 9998
. it'll work way. here's demo:
class="snippet-code-css lang-css prettyprint-override">body { width: 100%; height: 500px; } #wrapper { width: 100%; height: 100%; } #explorer { width: 13%; min-height: 100%; height: 100%; position: relative; float: left; } #v-dragbar { background-color: black; height: 100%; float: right; width: 2px; cursor: col-resize; z-index: 9999; position: relative; } #h-dragbar { background-color: black; width: 100%; height: 2px; cursor: row-resize; position: absolute; bottom: 0; z-index: 999; } #h-dragbar:hover { background-color: blue; } #v-dragbar:hover { background-color: blue; } #locations { height: 50%; width: 100%; position: relative; z-index: 9998; /*imp*/ }
class="snippet-code-html lang-html prettyprint-override"><div id="wrapper"> <div id="explorer"> <div id="v-dragbar"></div> <span style="clear: both;"></span> <div id="locations"> <div id="h-dragbar"></div> </div> <div id="datapoints"> </div> </div> <div id="explorer"> </div> </div>
html css
Comments
Post a Comment