CSS 二行缩进不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6297391/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS second-line indent not working
提问by R.J.
Page in question: http://www.rjlacount.com/public/lander/
有问题的页面:http: //www.rjlacount.com/public/lander/
I'm probably just doing something stupid, but I'm trying to indent the second line of wrapping text inside the form (with "Your account: [email protected]" at the top) and I can't seem to get anything to work.
我可能只是在做一些愚蠢的事情,但我试图缩进表单中第二行换行文本(顶部带有“您的帐户:[email protected]”),但我似乎什么也得不到上班。
I would think the solution is:
我认为解决方案是:
form span {padding-left:1.5em;text-indent:-1.5em;}
but this only seems to indent the first line of each section.
但这似乎只是缩进了每个部分的第一行。
Another look at this would be much appreciated, thanks!
再看看这个将不胜感激,谢谢!
回答by Omer
If the element is inline it will indent the first line, otherwise if it's a block element it will indent the rest of the lines, which is just like Briguy37 said, since that's the difference between DIV and SPAN. I just wanted to clear out that it's not a "problem with span".
如果元素是内联的,它将缩进第一行,否则如果它是块元素,它将缩进其余的行,就像 Briguy37 所说的那样,因为这是 DIV 和 SPAN 之间的区别。我只是想澄清一下,这不是“跨度问题”。
回答by Briguy37
回答by imamerican
spans are handled as inline elements.
跨度作为内联元素处理。
Considering them as actual characters helps to conceptualize the changes. A space after a span is retained because it's like a space between characters. You adjust height by line-height rather than simply height. etc etc
将它们视为实际角色有助于概念化这些变化。保留跨度后的空格,因为它就像字符之间的空格。您可以通过 line-height 而不是简单的高度来调整高度。等等等等
Usually if this is causing a problem you can just use a div and set display:inline-block; if you need horizontal alignment.
通常,如果这导致了问题,您可以使用 div 并设置 display:inline-block; 如果您需要水平对齐。