[英]Is it possible to target <p> </p> with just CSS?
I know I can remove p tags only with
我知道我只能用
删除 p 标签being in them with JS/jQuery like so:像这样使用 JS/jQuery 在其中:
$("p").filter(function(){
return $.trim(this.innerHTML) === " "
}).remove();
But is it possible to target these with just CSS.但是是否可以仅使用 CSS 来定位这些。 Something like these doesn't work:
像这样的东西不起作用:
p[ ] { display: none; }
p:contains(' ') { display: none; }
Unfortunately this isn't possible with just CSS.不幸的是,这仅靠 CSS 是不可能的。
:contains
used to be part of the CSS3 spec but has now been removed. :contains
曾经是 CSS3 规范的一部分,但现在已被删除。
I have the same problem, and I solved with CSS pseudo selector: 'has:'我有同样的问题,我用 CSS 伪选择器解决了:'has:'
p:has(' ') {
display: none;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.