<br> 元素在 div 和输入之间不工作

<br> element not working between div and input

下面是我正在使用的代码。出于某种原因,我无法在 div.chatBox 和要显示的输入之间获取 br。谁能给我一些建议。

<div class="container-fluid col-xs-12">
    <div class="row">
        <br>
        <div class="chatBox col-xs-5 col-xs-offset-3" id="chatBox">
        </div>

        <br>

        <input type="text" class="col-xs-offset-4 col-xs-3">
    </div>
</div>

根据 bootstrap 指南,您的 div 元素应具有 row class.
然后您可以添加样式作为 1em 的边距为他们而不是使用隔断线。

您使用 <br/> 标签的方式将没有效果,因为 <div> 已经是一个块元素,这就是原因,您觉得 <br> 标签不起作用。

如果你想添加一些 space 然后使用 &nbsp;

正如 evolutionxbox 所说,您必须使用 css 来正确显示您的元素。

但是你的 br 标签工作正常,只是你的第一个 div 是空的,所以你看不出有什么区别,试试这两个示例,有和没有 br.

<div class="container-fluid col-xs-12">
    <div class="row">
        <br>
        <div class="chatBox col-xs-5 col-xs-offset-3" id="chatBox" style="background-color:red;width:160px;height:100px">
        </div>

        <br/>

        <input type="text" class="col-xs-offset-4 col-xs-3">
    </div>
</div>

<div class="container-fluid col-xs-12">
    <div class="row">
        <br>
        <div class="chatBox col-xs-5 col-xs-offset-3" id="chatBox" style="background-color:red;width:160px;height:100px">
        </div>

        

        <input type="text" class="col-xs-offset-4 col-xs-3">
    </div>
</div>

我的 class 是 bootstrap,所以我所做的就是添加一个 ID,例如:

<div class="col-lg-12"  id="bottom_row_home">

然后在我的 css 中,我使用了

#bottom_row_home {
  padding-top: 50px;
}

这让我在两 div 行之间有了一点 space。