Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何使用CSS在BR标记后添加em空格( )_Html_Css_Line Breaks_Text Indent - Fatal编程技术网

Html 如何使用CSS在BR标记后添加em空格( )

Html 如何使用CSS在BR标记后添加em空格(&emsp;),html,css,line-breaks,text-indent,Html,Css,Line Breaks,Text Indent,我想在BR标签后面添加一个em空格,以实现文本缩进效果。但是下面的样式在我的Chrome上不起作用 或者,是否有其他方法在BR标记后实现文本缩进效果 <style> br::after { content: "&emsp;"; } </style> <p>Note:<br>For this selector to work in IE8, a DOCTYPE must be declared, and you must use th

我想在BR标签后面添加一个em空格,以实现文本缩进效果。但是下面的样式在我的Chrome上不起作用

或者,是否有其他方法在BR标记后实现文本缩进效果

<style>
br::after { 
  content: "&emsp;";
}
</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>

我设法做到了这一点,添加了一个em空间后,BR标签

<style>
br {
  content: '';
  white-space: pre;
}

br::after { 
  content: "\A\2003";
}
</style>
另一个问题是,我还想保持1米的利润底部。仅以下样式就可以很好地工作

<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>

在现代网页设计中,你真的不应该使用换行br标签来分隔段落。有关一些示例,请参见

此外,还有一个CSS属性text indent,它还实现了您所追求的文本缩进

基本上,使用如包装段落,然后对p标记应用文本缩进

p{ 文本缩进:1em; } p、 无牵连{ 文本缩进:继承; }

注意:

要使此选择器在IE8中工作,必须声明DOCTYPE,并且必须使用旧的单冒号CSS2语法:after而不是::after

这里有另一段话来说明当你有超过一个p的内容时这是如何应用的。所有主要浏览器都支持文本缩进属性。也就是说,3岁以后。IE不再是主流浏览器了


有关更多信息,请参见此处:https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent

我的意思是,你不应该像这样使用BR标签。此外,这基本上正是文本缩进属性的用途。这是一个框架挑战,因为BR标记不应该像这样使用,而且有一种内置的方式来进行文本缩进,这种方式一直存在。请注意::after inserts作为所选元素的开头,而不是在元素后面。