Maison >interface Web >tutoriel HTML >CSS经典布局之圣杯布局、双飞翼布局_html/css_WEB-ITnose
当我们在用CSS进行页面布局时,常常会遇到:三栏布局,两边顶宽,中间自适应且优先渲染。回想我们所接触过的QQ空间,人人网等个人主页时,常常会遇到此类的布局方式,因此我们应该如何解决?
<meta charset="UTF-8"> <title>圣杯布局</title><style> *{ margin: 0; padding: 0; } h3{ color: gray; } .header{ height: 100px; margin: 0 auto; border: 2px solid black; } .footer{ height: 100px; margin: 0 auto; border: 2px solid black; } .artice{ height: 500px; margin: 15px auto; border: 2px solid black; padding-left: 250px; padding-right: 200px; } .artice .left{ background-color: paleturquoise; float: left; width: 250px; height: 500px; margin-left: -100%; position: relative; left: -250px; } .artice .right{ background-color: #ff7d8e; float: left; width: 200px; height: 500px; margin-left: -200px; position: relative; right: -200px } .artice .middle{ background-color: pink; float: left; width: 100%; height: 500px; }</style><div class="header"> <h3>This is Top</h3> </div><div class="artice"> <div class="middle"> <h3>This is Main</h3> </div> <div class="left"> <h3>This is left</h3> </div> <div class="right"> <h3>This is right</h3> </div> </div><div class="footer"> <h3> This is L's page</h3> </div>
<meta charset="UTF-8"> <title>双飞翼布局</title><style> *{ margin: 0; padding: 0; } h3{ color: gray; } .header{ height: 100px; margin: 0 auto; border: 2px solid black; } .footer{ height: 100px; margin: 0 auto; border: 2px solid black; } .artice{ height: 500px; margin: 15px auto; border: 2px solid black; /* padding-left: 250px; padding-right: 200px;*/ } .artice .left{ background-color: paleturquoise; float: left; width: 250px; height: 500px; margin-left: -100%; /* position: relative; left: -250px;*/ } .artice .right{ background-color: #ff7d8e; float: left; width: 200px; height: 500px; margin-left: -200px; /* position: relative; right: -200px*/ } .artice .middle{ background-color: pink; float: left; width: 100%; height: 500px; } .inner{ margin-left: 250px; margin-right: 200px; }</style><div class="header"> <h3>This is Top</h3> </div><div class="artice"> <div class="middle"> <div class="inner"> <h3>This is Main</h3> </div> </div> <div class="left"> <h3>This is left</h3> </div> <div class="right"> <h3>This is right</h3> </div> </div><div class="footer"> <h3> This is L's page</h3> </div>
版权声明:本文为博主原创文章,未经博主允许不得转载。