本文介绍了在css中更改visibility属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<style>
#count2{
visibility:hidden;
}
#count1:hover{
background:#123456;
//how do I change the visibility property of #count2 here?
}
</style>
<div id="count1">My visible element</div>
<div id="count2">My flickering element</div>
我的问题很清楚,可能有点奇怪。如果有人在#count1上只使用css,则将#count2的visibility属性更改为true。
My question is clear and might be little weird though. How do I change the visibility property of #count2 to true when somebody hovers on #count1, using only css.
推荐答案
在悬停其中一个元素时修改两个不同的元素,可以在单独的规则中使用同级组合器,然后使用#count2
选择器来修改该特定元素:
Since you're modifying two different elements on hovering one of them, you can use a sibling combinator followed by the #count2
selector in a separate rule for modifying that particular element:
#count2 {
visibility: hidden;
}
#count1:hover {
background: #123456;
}
#count1:hover + #count2 {
visibility: visible;
}
这篇关于在css中更改visibility属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!