简体   繁体   English

为什么我在第一个空格上不使用空格预换行和单词空格来设置空格宽度

[英]Why do I Use white-space pre-wrap and word-space not working on the first space to set up the width of space

I use white-space: pre-wrap for space at the beginning of tag. 我使用white-space: pre-wrap在标签开头white-space: pre-wrap空格。 And use word-spacing:1em to setup the space width. 并使用word-spacing:1em设置空间宽度。

But there is a problem that the space at the beginning of the tag is not 1em width, and other spaces are all right except it. 但是存在一个问题,即标签开头的空间不是1em宽度,其他空间都可以。

the code: 编码:

 p{ white-space: pre-wrap; word-spacing:1em; } 
 <p> This is a paragraph.</p> <p> This is a paragraph.</p> 

My problem is how to change the width of space at the beginning of tag. 我的问题是如何在标签的开头更改空间的宽度。

The word-spacing property will only affect the space between two words, so i would add this: word-spacing属性只会影响两个单词之间的间隔,因此我将添加以下内容:

p 
{
   padding-left: 1em;
}

You can also use the text-indent. 您也可以使用文本缩进。 The text-indent CSS property sets the length of empty space (indentation) that is put before lines of text in a block. text-indent CSS属性设置块中文本行之前的空白(缩进)长度。

p { white-space: pre-wrap; word-spacing: 1em; border: 1px solid; text-indent: 1em}

Read more here: https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent 在此处阅读更多信息: https : //developer.mozilla.org/en-US/docs/Web/CSS/text-indent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM