html/css 布局练习3

效果图:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>无标题文档</title>
 6 <style>
 7 .body{width:300px;height:300px; margin:100px; border:10px solid #CCC;}
 8 .left{width:150px; height:300px; background-color:#3C9; float:left;}
 9 .top{width:150px; height:100px; background-color:#FC6; float:left;}
10 .center{width:150px; height:100px;}
11 .centerleft{width:75px; height:100px; background-color:#F09; float:left;}
12 .centerright{width:75px; height:100px; background-color:#9FF; float:left;}
13 .bottom{width:150px; height:100px; background-color:#69F; float:left;
14 </style>
15 </head>
16 
17 <body>
18 <div class="body">
19     <div class="left"></div>
20     <div class="top"></div>
21     <div class="centerleft"></div>
22     <div class="centerright"></div>
23     <div class="bottom"></div>
24 
25     
26 </div>
27 </body>
View Code

 自己过了几天利用after伪类+zoom的另一种写法:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5 <title>无标题文档</title>
 6 <style>
 7 .clear{zoom:1;}
 8 .clear:after{content:""; display:block; clear:both;}
 9 .wrap{width:500px;margin:0 auto;border:10px solid #ccc;}
10 .left{width:200px;height:400px;background:#7a1;float:left;}
11 .right{width:300px; float:right;}
12 .right_top{height:80px; background-color:#F90;}
13 
14 .right_center_left{width:150px;height:160px;background:#f69; float:left;}
15 .right_center_right{width:150px;height:160px;background-color:#FCC; float:left;}
16 .bottom{height:160px;background:#369;}
17 </style>
18 </head>
19 
20 <body>
21 <div class="wrap clear">
22     <div class="left">
23     </div>
24     <div class="right">
25         <div class="right_top"></div>
26         <div class="right_center clear">
27             <div class="right_center_left"></div>
28             <div class="right_center_right"></div>
29         </div>
30         <div class="bottom"></div>
31     </div>
32 </div>
33 </body>
34 </html>
View Code

效果图:

转载于:https://www.cnblogs.com/baoweiluobo/p/5819313.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值