Front-end style notes

Two situations: 1. The text format is centered; 2. The label where the text is located is centered and displayed in the window.

1. As other anonymous users answered, just add the CSS attribute value "text-align:center" to the label where the text is located. E.g:

1

<p style="text-align:center">我是文本,居中显示</p>

2. There are many methods, two are introduced here, for example:

1) (Recommendation) The text should be wrapped by an inline label or an inline block-level label, and the inline label or an inline block-level label should be wrapped by a block-level label. In this way, the text format will be centered. If you want the text format not to be centered, you can add the CSS property value "text-align:left" or other inline tags or block-level tags.

1

2

3

4

<div style="text-align:center"<!-- 块级标签 -->

    <span>我是文本所在标签1,文本居中显示<span<!-- 行内标签 -->

    <div style="display:inline-block;">我是文本所在标签2,文本居中显示</div<!-- 行内块级标签 -->

</div>

2) The text is wrapped by block-level tags. Set the width for the block label and add the CSS property value "margin:0 auto". In this way, the text format will not be centered. If you want the text format to be centered, you can add the CSS property value "text-align:center" to the block-level tag.

1

<div style="width: 100px; margin:0 auto">我是文本所在标签,文本居中显示</div>

 

Guess you like

Origin blog.csdn.net/xkx_07_10/article/details/103819679