[英]select next element CSS
i have 2 div elements in html : 我在html中有2个div元素:
<body>
<div id="one"></div>
<div></div>
</body>
I want to hide div elements after div with id="one"
from CSS, I tried this : 我想在CSS之后用div
id="one"
隐藏div元素,我试过这个:
#one:after{display:none}
This doesn't work any other way to do? 这不能用于其他任何方式吗?
:after
applies to generated content. :after
适用于生成的内容。 You want the adjacent sibling combinator : 你想要相邻的兄弟组合器 :
#one + * {
}
If you know the exact position of the child element (like in you case its 2nd child), you can use nth-child pseudo class 如果你知道子元素的确切位置(就像你的第二个孩子一样),你可以使用nth-child伪类
div:nth-child(2)
{
display:none;
}
Fiddle: http://jsfiddle.net/ankur1990/HDq2T/ 小提琴: http : //jsfiddle.net/ankur1990/HDq2T/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.