Reputation: 3505
this is my sample stylesheet
<style>
.cover{ margin 0 auto;}
.cover .ab{ display:inline-block color:#000; height:25px;}
while hover the class .ab class .ac should drop from -25px from 0px
.cover .ab:hover .ac{ top:0px }
.ac{ position:absolute; top:-25px; height:25px;}
</style>
my html looks like
<body>
<div class="cover">
<div class="ab"> </div>
</div>
<div class="ac"> </div>
</body>
it doesn't seems to works is there anything wrong in statement please help me thanks n advance.
Upvotes: 2
Views: 424
Reputation: 28528
you can achieve it if both of your divs are siblings:
<div class="cover">
<div class="ab">asdfa</div>
<div class="ac">test</div>
</div>
then css:
.ab:hover ~ .ac{ top:0px;height:25px; }
would work for you working Demo.
The general sibling combinator (~
) works for siblings.
you can move your .ac
div in .cover
div or apply css on .cover
div:
.cover:hover ~ .ac { top:0px }
Upvotes: 0
Reputation: 123739
Use Sibling selector over Cover. Demo
.cover:hover ~ .ac { top:0px }
Upvotes: 2
Reputation: 9929
.cover .ab:hover .ac { top:0px }
This is not working since .ac is not a child of .ab (and also not a child of .cover by the way).
Upvotes: 3