css - Blockquote 添加了额外的 <br>

标签 css blockquote

为什么 blockquote 在它的末尾添加了一个额外的 br,我该如何避免它? 我怎样才能删除添加的额外 br 以便我的所有行都在一起>

.container-content .main-content .container-test pre {
  font-family: monospace;
  white-space: pre;
  word-break: break-all;
  color: #ececec;
  border: none;
  padding: 0;
  background-color: transparent;
}

blockquote {
  padding: 0px 10px 0px;
  margin: 0 0 0px;
  border-left: 3px solid #2471A3;
}
<div class="container-test">
<pre>
test test tesst
test test tesst
test test tesst
test test tesst
<blockquote>test test tesst
test test tesst
test test tesst
test test tesst</blockquote>
test test tesst
test test tesst
test test tesst
test test tesst
</pre>
</div>

最佳答案

为什么你有一个额外的br的原因在你的 block 引用之后是因为你正在使用 <pre>标签。 pre标记格式的文本与您在代码中的编写方式完全相同。所以这里有两个解决方案

  1. 按照您希望的方式格式化代码

.container-test {
  font-family: monospace;
}

blockquote {
  padding: 0px 10px 0px;
  margin: 0 0 0px;
  border-left: 3px solid #2471A3;
}
<div class="container-test">
<pre>
test test tesst
test test tesst
test test tesst
test test tesst
<blockquote>test test tesst
test test tesst
test test tesst
test test tesst</blockquote>test test tesst
test test tesst
test test tesst
test test tesst
</pre>
</div>

  1. 避免使用 pre完全,并为您的容器添加宽度。

.container-test {
  font-family: monospace;
  width: 150px;
}

blockquote {
  padding: 0px 10px 0px;
  margin: 0 0 0px;
  border-left: 3px solid #2471A3;
}
<div class="container-test">
test test tesst
test test tesst
test test tesst
test test tesst
<blockquote>
test test tesst
test test tesst
test test tesst
test test tesst
</blockquote>
test test tesst
test test tesst
test test tesst
test test tesst
</div>

您可以阅读有关 pre 的更多信息标签 here .

关于css - Blockquote 添加了额外的 <br>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48141364/

相关文章:

html - 循环中的等高 Bootstrap 框

html - 如何在链接文本下对齐 Material 图标?

html - 居中并使 block 引用元素响应

css - 与 block 引用中的文本关联的不透明度

html - Bootstrap 4.1.3 : sidebar doesn't show up when applying blockquote class

jquery - 无法使用 Bourbon Refills

css - 使用视频时的布局问题

html - 如何获得边界重叠?

html - 如何对齐 block 引用的开引号和闭引号?

html - 在带有 CSS 的文本之前显示 Bootstrap 图标显示代码而不是图标