Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/35.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 如何在我的<;h2>;居中_Html_Css - Fatal编程技术网

Html 如何在我的<;h2>;居中

Html 如何在我的<;h2>;居中,html,css,Html,Css,我正在使用标记。标题显示为左对齐。如何使文本显示在的中心?使用CSS文本对齐属性: text-align: center; 此属性的其他值包括左、右和对正使用CSS文本对齐属性: text-align: center; 此属性的其他值包括左、右和对正使用CSS文本对齐属性: text-align: center; 此属性的其他值包括左、右和对正使用CSS文本对齐属性: text-align: center; 此属性的其他值包括left、right和justify在Css中,使用text

我正在使用
标记。标题显示为左对齐。如何使文本显示在
的中心?

使用CSS
文本对齐属性:

text-align: center;

此属性的其他值包括
对正

使用CSS
文本对齐
属性:

text-align: center;

此属性的其他值包括
对正

使用CSS
文本对齐
属性:

text-align: center;

此属性的其他值包括
对正

使用CSS
文本对齐
属性:

text-align: center;

此属性的其他值包括
left
right
justify
在Css中,使用
text align:center
到特定标记

示例 html

<h2 class="aligncenter">Welcome</h2>

在Css中,使用
text align:center
到特定标记

示例 html

<h2 class="aligncenter">Welcome</h2>

在Css中,使用
text align:center
到特定标记

示例 html

<h2 class="aligncenter">Welcome</h2>

在Css中,使用
text align:center
到特定标记

示例 html

<h2 class="aligncenter">Welcome</h2>
试试这个:

h2{
   width: 100%;
   text-align: center;
}
试试这个:

h2{
   width: 100%;
   text-align: center;
}
试试这个:

h2{
   width: 100%;
   text-align: center;
}
试试这个:

h2{
   width: 100%;
   text-align: center;
}

使用
text align:center
应该可以工作,但是如果您使用的是float或display:inline/inline块属性,那么您需要使用
margin:0 auto
或give
width:100%
然后使用
text align:center
。使用
text align:center
应该可以工作,但是如果您使用的是float或display:内联/内联块属性则需要使用
margin:0 auto
或give
width:100%
,然后使用
text align:center
。使用
text align:center
应该可以,但如果使用float或display:inline/inline块属性,则需要使用
margin:0 auto
或give
width:100%
然后
文本对齐:居中
。使用
文本对齐:居中
应该可以工作,但如果使用浮点或显示:内联/内联块属性,则需要使用
边距:0自动
或给定
宽度:100%
然后
文本对齐:居中
h2
默认为
显示:块
表示不需要
宽度:100%
h2
默认为
display:block
,表示不需要
宽度:100%
h2
默认为
显示:块
,表示不需要
宽度:100%
h2
默认为
显示:块
,这意味着不需要
宽度:100%