这是一个非常小的HTML问题,我相信你们会很快回答的。我在我的网站上张贴的东西是这样的
<div id="content">
<p>
<hh>Header text here</hh>
Post information here, text and stuff.
</p>
<p>
<hh>Header 2 text here</hh>
Post 2 information here, text and stuff.
</p>
</div>
但是,当我尝试插入<center>
或left标记时,<p>
会自动关闭,并且<center>
标记之后的所有内容都在段落框之外。我在firefox中使用了inspect-element,在调用居中文本之前,我可以看到它以一个我从未输入过的</p>
结束。
例如:
<p>
<hh>Header 2 text here</hh>
Post 2 information here, text and stuff.
<center>This text is centered</center>
</p>
是这样渲染的:
<p>
<hh>Header 2 text here</hh>
Post 2 information here, text and stuff.
</p>
<center>This text is centered</center>
</p>
这真的很令人沮丧,如果有人能帮助我,那就太好了。使用<div align-right>
也不起作用。如果它有帮助,我可以将整个<p>
设置为以任何方式对齐,它就会工作。
只有当我与该标签中的设置方向不同时,它才会断开。
发布于 2013-01-03 08:09:24
来自w3school:
使用CSS居中显示文本!
HTML5中不支持该标记。请改用CSS。
HTML 4.01中不推荐使用该元素。
http://www.w3schools.com/tags/tag_center.asp
因为center的作用就像p,你不能把p放在p里。
编辑:要回复你的评论,你可能应该这样做:
<p>
<hh>Header 2 text here</hh>
Post 2 information here, text and stuff.
<span>This text is centered</span>
<p>
在你的css中添加这个
#content p span { display:block; text-align:center; }
(如果您需要的话,它也可以与a标签一起使用)
发布于 2013-01-03 08:07:34
这可能是因为您不能在p-tag中使用hh-tag。(不确定,但这主要是)
https://stackoverflow.com/questions/14131199
复制相似问题