<br /> 标记后不显示边距

Rob*_*b F 2 html css margin line-breaks

我有以下(摘录)html:

<span id="version">Version 1 <small>Last modified 04/August/2012</small><br>unfinished</span>
Run Code Online (Sandbox Code Playgroud)

以及以下(摘录)CSS:

#version {
  font-size: xx-large;
  color: Black;
  text-align: left;
  margin-left: 35px;
}

#version small {
  font-size: 50%;
}
Run Code Online (Sandbox Code Playgroud)

在 <br> 之后,所有内容都会正确显示,其中文本不会根据边距进行调整。为什么<br>之后没有调整?

j08*_*691 5

因为span是一个内联元素。完成您想要的操作,将 span 上的显示属性设置为 block 或 inline-block,或者将 span 更改为 div。

jsFiddle 示例