Is there a css pseudo selector for overflow?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 11:59:32

问题


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!


回答1:


CSS cannot select based on used or computed styles of any kind, so you're out of luck.



来源:https://stackoverflow.com/questions/13213197/is-there-a-css-pseudo-selector-for-overflow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!