【发布时间】:2011-06-04 10:12:14
【问题描述】:
<html>
<style type="text/css">
h3{
display: block !important;
}
h3:active{
display: block !important;
}
h3 span:before{
content: "[-]";
}
h3:active span:before{
content: "[+]";
}
div#summary:active > h3, h3:active ~ h4, h3:active ~ ul{
display: none;
}
</style>
<body>
<div id="summary">
<h3>Click to hide<span></span></h3>
<ul><li>first</li></ul>
<h4>title 1</h4>
<ul><li>second</li></ul>
<h4>title 2</h4>
<ul><li>third</li></ul>
<h4>title 3</h4>
<ul><li>fourth</li></ul>
</div>
</body>
</html>
现场演示: http://jsfiddle.net/BxrJz/
它在 chrome 和 firefox 中工作,但我如何让它在 ie 中工作?还有,有没有办法让它一直处于隐藏状态,直到再次点击,就不用一直按住了?
【问题讨论】:
-
应该发生什么?
-
我知道您可以通过单击并拖动鼠标离开链接然后释放来保持链接处于活动状态。也许如果您更改活动元素的位置或将其隐藏起来,您可以获得相同的效果......(顺便说一句,到目前为止您所拥有的东西非常酷)
-
@JMC Creative - 它应该隐藏 h4 和 ul 元素
-
IE 对 CSS 选择器的支持非常差,尤其是在 IE6 中,基本上不存在支持。 7的稍微好一点,8的更好。 9 可能会有相当完整的支持。
-
实际上,如果您扩展 :hover 元素的大小以覆盖整个窗口(但 AFAIK 不在外部 - 例如在 chrome 中),您可以保持该状态
标签: css internet-explorer css-selectors