是否有一个css伪选择器溢出? [英] Is there a css pseudo selector for overflow?
问题描述
。 我试图改变基于它的东西的样式或不是它的父div被溢出。 pDiv {display:block;宽度:300px; height:100px; border:1px solid rgb(0,0,0); }
.cDiv {display:block;填充4px; border-bottom:1px solid rgb(0,0,0);
.pDiv:溢出.cDiv {border-bottom:none; }
< div class =pDiv>< div class =cDiv>孩子1< / div>< div class =cDiv> ;< div class =cDiv> child 3< / div>< div class =cDiv> child 4< / div>< div class =cDiv> ; / DIV>
是否可以做这样的事情?我会使用最后一个孩子的伪选择器,但是孩子的数量可能会有所不同,所以我希望它只在父级div被溢出时才删除最后一个孩子的边界底部。我想要一个纯粹的CSS解决方案,请不要JS!
解决方案CSS不能根据任何类型使用或计算的样式进行选择,所以你运气不好。
I'm trying to alter the style of something based on wether or not its parent div is being overflown.
.pDiv { display: block; width: 300px; height: 100px; border: 1px solid rgb(0,0,0); }
.cDiv { display: block; padding 4px; border-bottom: 1px solid rgb(0,0,0);
.pDiv:overflow .cDiv { border-bottom: none; }
<div class="pDiv"><div class="cDiv">child 1</div><div class="cDiv">child 2</div><div class="cDiv">child 3</div><div class="cDiv">child 4</div><div class="cDiv">child 5</div></div>
is it possible to do something like this? I would use the last-child pseudo-selector, but the number of children can vary, so I want it to remove the border-bottom of the last-child ONLY IF the parent div is being overflown. I want a pure CSS solution too please, no JS!
CSS cannot select based on used or computed styles of any kind, so you're out of luck.
这篇关于是否有一个css伪选择器溢出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!