简体   繁体   English

如何忽略HTML和CSS中的2条换行符?

[英]How to ignore 2 break lines in HTML and CSS?

I'm debugging an existing Java/JSP/Struts application, somehow it generates 2 break lines and left a large space in the page : 我正在调试现有的Java / JSP / Struts应用程序,以某种方式它会生成2条换行符,并在页面中留出很大的空间:

<Br></Br>
<Br></Br>

So I searched around and found I can use the following in CSS to ignore break lines : 所以我四处搜寻,发现我可以在CSS中使用以下内容来忽略换行符:

br { display: none; }

See my previous question : Where did extra space come from in html of Struts app? 看到我以前的问题: Struts应用程序的html的额外空间从哪里来?

But this will cause all break lines to be ignored in the app, and not the ideal solution I'm looking for, I think the br's were generated by Struts and hard to control, so I wonder if there is a way in CSS to define 2 breaks as nothing [to be ignored], maybe something like this ? 但这会导致应用中的所有换行符被忽略,而不是我想要的理想解决方案,我认为br是由Struts生成的并且难以控制,因此我想知道CSS中是否有一种方法可以定义2中断,什么也没发生[忽略],也许是这样?

brbr { display: none; }
br.br { display: none; }

I tried it, didn't work, must be in wrong format, any CSS experts here can answer my question ? 我尝试过,没有用,必须格式错误,这里有CSS专家可以回答我的问题吗?

Use + in your selector: 在选择器中使用+

br + br { display: none; }

From W3 Documentation 从W3文档

E + F : Matches any F element immediately preceded by a sibling element E. E + F :匹配紧随同级元素E的所有F元素。

Simple: 简单:

br + br {display:none;}

This selects a br that directly follows another br using the + selector. 这将选择一个br直接跟随另一br使用+选择器。

Ref: Section 5.1 Pattern matching and 5.7 Adjacent sibling selectors 参考: 5.1模式匹配5.7相邻兄弟选择器

br supports class why not give then a class br支持课程为什么不给然后课程

<br class="hey" />

CSS CSS

.hey{
display:none;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM