#############################################
<html> <head> <style type="text/css"> #adiv { width:300px; backgroud-color: #efefef; boarder: 2px solid black; } .aclass { border: 5px solid red; margin: 150px 100px 10px 40px; padding: 15px 20px 25px 30px; color: green; } </style> </head> <body> <p>This is test webpages! </p> <div id="adiv"> <div class="aclass">A B C D</div> </div> </body> </html>这个网页的显示效果如下图所示:
------------------------------------------------------------------------------------- margin |-----------------------------------------------------| | border | | |-------------------------------------------| | | | padding | | | | |--------------------------------| | | | | | content | | | | | |--------------------------------| | | | | | | | |-------------------------------------------| | | | |-----------------------------------------------------| --------------------------------------------------------------------------------------在浏览器解析的时候,我们会去将每一个element按照相对位置进行布局,然后进行排版位置的确定。