看起来div的text-indent是0px (这是默认的body text-ident大小),但是为什么它继承了body元素呢?为什么不继承作为div父元素的P元素,将text-indent设置为32px?
p {
text-indent: 32px;
}
div {
text-indent: inherit;
}<p>In my younger, he told me, ,
<div>'just remember that all the people in this world haven't had the advantages thatyou've had.'</div>
</p>
发布于 2017-05-23 15:45:25
文本缩进属性指定文本块中第一行的缩进,而不是所有行。
阅读更多信息:https://www.w3schools.com/cssref/pr_text_text-indent.asp
从语法上讲,p中的在所有HTML标准中都是无效的。
阅读更多信息:Nesting block level elements inside the tag... right or wrong?
您可以使用span而不是div。
这样的 :
p {
margin-left: 32px;
}<p>In my younger, he told me,<br><br>
<span>'just remember that all the people in this world haven't had the advantages thatyou've had.'</span>
</p>
如果您想使用缩进坚持,请使用margin-left表示div。
p {
text-indent: 32px;
}
div {
margin-left: 32px;
}<p>In my younger, he told me,
<div>'just remember that all the people in this world haven't had the advantages thatyou've had.'</div>
</p>
发布于 2017-05-23 15:49:35
您不能将"div“标记插入到在html中无效的"p”标记内。但是你可以在"div“标签中插入"p”标签。如果希望子元素继承"p“元素属性,只需将"div”更改为"p“即可。
发布于 2017-05-23 15:54:24
使用<span>而不是<div>
不能在<p>中插入在html中无效的<div>标记。
<p>In my younger, he told me, ,
<span>'just remember that all the people in this world haven't had the advantages that you've had.'</span>
</p>希望这能对你有所帮助
https://stackoverflow.com/questions/44128700
复制相似问题