菜鸟学堂
在线运行
源代码
<!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>
运行结果
在线运行
菜鸟学堂 edu.jb51.net