html - 如何使用 CSS 在 BR 标签后添加 em 空格()
问题描述
我想在 BR 标签之后添加一个 em-space 以实现文本缩进效果。但以下 STYLE 不适用于我的 Chrome。
或者,还有什么其他方法可以在 BR 标签之后实现文本缩进效果?
<style>
br::after {
content: " ";
}
</style>
<p>Note:<br>For this selector to work in IE8, a DOCTYPE must be declared, and you must use the old, single-colon CSS2 syntax (:after instead of ::after).</p>
解决方案
你真的不应该使用换行符 (br) 标签来分割段落,而不是在现代网页设计中。有关示例,请参阅HTML 5.2 规范。
此外,还有一个 CSS 属性text-indent
也可以实现您所追求的文本缩进。
基本上,<p>
按预期使用(例如,换行)然后应用于text-indent
标签p
。
p {
text-indent: 1em;
}
p.unindented {
text-indent: inherit;
}
<p class="unindented">Note:</p>
<p>For this selector to work in IE8, a DOCTYPE must be declared, and you must use the old, single-colon CSS2 syntax (:after instead of ::after).</p>
<p>Here is another paragraph to show how this applies when you have more than one <p> of content. The text-indent property is supported by all major browsers. (That is, IE 3 and later. Not that IE is a major browser anymore....)</p>
<p>See here for more info: https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent</p>
text-indent
是一个非常古老的属性,在所有主要浏览器和许多旧浏览器中都有广泛的支持。它最初是在 IE 3 中引入的,以了解它的历史。有关更多信息,请参阅MDN。
推荐阅读
- python - 在 python 中使用 nurbs / geomdl 在 3D b 样条上查找点的曲率中心
- date - SQL Developer 定义日期
- javascript - json-rules-engine 处理对象数组
- go - 在 Visual Studio 代码中调试 cgo 会产生“多重定义”错误
- python - 绘制 n 次函数的图形
- java - Kafka Consumer - 从每个分区读取 2000 条 LATEST 消息
- c++ - 为什么将一个指针分配给另一个指针会改变 cpp 中的原始指针?
- swift - 从 anyObject 到坐标数组
- office-js - Outlook 加载项可操作消息“Action.InvokeAddInCommand”在 OWA 中没有模式
- amazon-web-services - EMR 集群卡在调整大小上