我有一大段的文本,分为<br>的子段落:

<p>
  Blah blah blah.
  <br/>
  Blah blah blah. Blah blah blah. Blah blah blah.
  <br/>
  Blah blah blah.
</p>

我想扩大这些分段之间的间隔,比如有两个<br>之类的。我知道这样做的正确方法是使用<p></p>,但现在我不能改变这个布局,所以我正在寻找css的解决方案。

我试着用display: block设置<br>的行高和高度,我也谷歌了一下,堆栈溢出了,但没有找到任何解决方案。在不改变布局的情况下,这可能吗?


当前回答

Css:

br {
   display: block;
   margin: 10px 0;
}

解决方案可能不跨浏览器兼容,但至少是可以的。还可以考虑设置行高:

line-height:22px;

对于谷歌Chrome浏览器,考虑设置内容:

content: " ";

除此之外,我认为您只能使用JavaScript解决方案了。

其他回答

而不是

<br>,<br/>,<hr> or <span></span> and trying different CSS properties to these tag.

我做了,我把段落放在一个div中,并给它行高:2px

# html

<div class="smallerlineHeight">
   <p>Line1</p>
   <p>Line2</p>
</div>

#css

.smallerlineHeight {
    p {
        line-height: 2px;
    }
}

我使用这些方法,但我不知道是否跨浏览器

方法一======

br {
    display:none;
}

或 ======方法二======

br {
    display: block;
    margin-bottom: 2px;
    font-size:2px;
    line-height: 2px;
}
br:before {
    display: block;
    margin-top: 2px;
    content: "";
}
br:after {
    content: ".";
    visibility: hidden;
    display: block;
}

或 ======方法三======

br:after { content: "" }
br { content: "" }

Css:

br {
   display: block;
   margin: 10px 0;
}

解决方案可能不跨浏览器兼容,但至少是可以的。还可以考虑设置行高:

line-height:22px;

对于谷歌Chrome浏览器,考虑设置内容:

content: " ";

除此之外,我认为您只能使用JavaScript解决方案了。

所以,上面的人基本上得到了类似的答案,但在这里它非常简洁。适用于Opera, Chrome, Safari和Firefox,最有可能也适用于IE ?

br {
            display: block; /* makes it have a width */
            content: ""; /* clears default height */
            margin-top: 0; /* change this to whatever height you want it */
}

另一种方法是使用人力资源。但是,狡猾的是,让它隐形。

因此:

<hr style="height:30pt; visibility:hidden;" />

使用HR来模拟一个更干净的BR中断:Btw适用于所有浏览器!!

{ height:2px; visibility:hidden; margin-bottom:-1px; }