首页
极刻
圈子
教程
开源
极客社区
写文章
发极刻
建圈子
发项目
登录 / 注册
返回教程:CSS 教程
TRY RUN / 在线示例
CSS 教程 实例
CSS 教程 实例
源代码
运行
<!DOCTYPE html> <html> <head> <style> .container { text-align:center; } .center { margin-left:auto; margin-right:auto; width:70%; background-color:#b0e0e6; text-align:left; } </style> </head> <body> <div class="container"> <div class="center"> <p>In my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.</p> <p>'Whenever you feel like criticizing anyone,' he told me, 'just remember that all the people in this world haven't had the advantages that you've had.'</p> </div> </div> <p><b>Note:</b> In IE5 there is a margin handling bug for block elements. Block elements are sometimes treated as inline content. This is particularly problematic when it comes to centering. For centering to work in IE5, use the text-align property, like in this example.</p> </body> </html>
运行结果