我想在BR标签后面加一个空格,以达到文本缩进的效果。但以下风格在我的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>发布于 2019-09-25 09:55:45
你真的不应该使用换行(br)标签来分隔段落,在现代网页设计中是不应该的。有关示例,请参阅HTML 5.2 spec。
此外,还有一个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是一个非常古老的属性,它广泛支持所有主流浏览器,也支持很多更老的浏览器。它最早是在IE3中引入的,目的是让人们了解它有多老。有关详细信息,请参阅MDN。
发布于 2019-09-25 09:25:14
我设法在BR标签后面添加了一个em空格!
<style>
br {
content: '';
white-space: pre;
}
br::after {
content: "\A\2003";
}
</style>另一个问题是,我也想保持1em的边际底部。下面的风格本身就能很好地工作。
<style>
br {
content: '';
display: block;
margin-bottom: 1em;
}
</style>但是,如果我将这两种风格混合到下面的代码中,它就不能工作了!
<style>
br {
content: '';
white-space: pre;
display: block;
margin-bottom: 1em;
}
br::after {
content: "\A\2003";
}
</style>https://stackoverflow.com/questions/58089465
复制相似问题