3 回答
TA贡献3593条经验 获得超1个赞
TA贡献14条经验 获得超3个赞
左右DIV都自适应布局,用百分比来定义宽度。记得要清楚浮动!
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#000}
.top{height:100px;background:#9FC;}
.main,.left,.right{height:600px;background:#F00; }
.main:after{display:table;clear:both}
.right{float:right;background:#993; width:75%;}
.right_l,.left_l{width:5px; background:#F00; height:inherit}
.right_l{float:left;}
.right_r{float:right;}
.left{width:25%;background:#00C; float:left;}
.left_l{ float:right;}
.left_r{ float:left;}
.foot{height:50px;background:#666;}
</style>
</head>
<body>
<div class="top">21112top</div>
<div class="main">
<div class="right">
<div class="right_l"></div>
<div class="right_r">right</div>
</div>
<div class="left">
<div class="left_l"></div>
<div class="left_r">left</div>
</div>
</div>
<div class="foot">foot</div>
</body>
TA贡献17条经验 获得超8个赞
1.左边定宽 右边自适应
左边float:left 右边margin-left:210px
<!doctype html>
<html>
<head>
<style type="text/css">
body{
margin:0;
padding:0;
/* font-size:30px;*/
color:#000;
}
.top{
height:100px;
background:#9FC;
}
.main,.left,.right{
height:600px;
background:#F00;
}
.right{
margin-left:210px;
background:#993;
}
.left{
width:200px;
background:#00C;
float: left;
}
.foot{
height:50px;
background:#666;
}
</style>
</head>
<body>
<div class="top">21112top</div>
<div class="main">
<div class="left">left</div>
<div class="right">right</div>
</div>
<div class="foot">foot</div>
</body>
</html>2 绝对定位
<!doctype html>
<html>
<head>
<style type="text/css">
body{
margin:0;
padding:0;
/* font-size:30px;*/
color:#000;
}
.top{
height:100px;
background:#9FC;
}
.main{
position: relative;
}
.main,.left,.right{
height:600px;
background:#F00;
}
.right{
position: absolute;
left: 210px;
top:0;
background:#993;
}
.left{
width:200px;
background:#00C;
}
.foot{
height:50px;
background:#666;
}
</style>
</head>
<body>
<div class="top">21112top</div>
<div class="main">
<div class="left">left</div>
<div class="right">right</div>
</div>
<div class="foot">foot</div>
</body>
</html>。。。还有一些 各有优缺点
TA贡献16条经验 获得超10个赞
两个div都左浮动:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#000}
.top{height:100px;background:#9FC;}
.main,.left,.right{height:600px;background:#F00;}
.right{float:left;margin-left:10px;background:#993;}
.left{float:left;width:200px;background:#00C;}
.foot{height:50px;background:#666;}
</style>
</head>
<body>
<div class="top">21112top</div>
<div class="main">
<div class="left">left</div>
<div class="right">right</div>
</div>
<div class="foot">foot</div>
</body>
</html>- 3 回答
- 0 关注
- 2354 浏览
相关问题推荐
添加回答
举报
