编辑下面的代码:【加编码】
<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>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂