CSS而悬停一个div如何显示其他类(或)div? [英] CSS while hover a div how to display other class(or) div?
本文介绍了CSS而悬停一个div如何显示其他类(或)div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的示例样式表
< style&
.cover {margin 0 auto;}
.cover .ab {display:inline-block color:#000;悬停类.ab类.ac应该从-25px下降到0px。 .cover .ab:hover .ac {top:0px}
.ac {position:absolute; top:-25px; height:25px;}
< / style>
我的html看起来像
< body>
< div class =cover>
< div class =ab>& nbsp;< / div>
< / div>
< div class =ac>& nbsp;< / div>
< / body>
它似乎不工作是有什么错误的语句请帮助我感谢n提前。
解决方案
.cover .ab:hover .ac {top:0px}
这不工作,因为.ac不是.ab的子项(也不是.cover的子项方式)。
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.
解决方案 .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).
这篇关于CSS而悬停一个div如何显示其他类(或)div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文