我有一些文本,我想同时在页面上居中,并将段落中的文本调整到左侧?帮个小忙?
这就是我一直在尝试的
<p align="center"><div align="left>text<br>more text</p></div>很明显,这不起作用,这只会转移剩下的所有内容
发布于 2012-09-20 09:08:02
麻烦的部分(尽管IE总是不同的)是,为了使项目居中,水平边距需要设置为自动(允许浏览器实际居中内容)。所以,with that being said
p.centered {
margin: 0px auto;
width: 300px;
border: 1px solid #f0f;
}
<p class="centered">This is your paragraph</p>width由您调用(为清楚起见,我添加了一个边框),但只要将侧面margin设置为auto,内容就会左对齐(除非text-align另有指定)。
发布于 2012-09-20 09:04:50
align="center"和align="left"已弃用。请改用CSS。
有一种方法可以做到这一点(假设您想要两个嵌套元素,或者查看Brad的居中单个元素的方法):http://jsfiddle.net/EzNJQ/1/
<div id="outer">
<p id="inner">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</p>
</div>
#outer{
width: 300px;
margin: 0 auto; /* centers */
}
#inner {
text-align: left;
}更多示例:http://www.w3.org/Style/Examples/007/center.en.html
https://stackoverflow.com/questions/12504818
复制相似问题