您的位置:首页 > Web前端 > CSS

css三列布局,最右侧div固定,其他两列自适应

2016-05-02 16:01 531 查看
<!DOCTYPE html>
<head>
<title>最右边div固定,其他两列宽度自适应</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>1-3-1一列固定,中间最右边div固定</title>
<meta name="description" content="">
<meta name="keywords" content="">
<style type="text/css">
*{
margin: 0;
padding: 0;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html {
min-height: 100%;
_height:100%;
height:100%;
}
body {
min-height: 100%;
_height:100%;
height:100%;
background: #fff;
font: 14px 宋体;
}
.rounded {
background: red;
width: 100%;
}
.rounded h2 {
background: orange;
padding: 20px 20px 10px;
margin: 0;
}
.rounded .main {
background: yellow;
padding: 10px 20px;
margin: -20px 0 0 0;
}
.rounded .footer {
background: green;
}
.rounded .footer p {
color: red;
text-align: right;
background: blue;
display: block;
padding: 10px 20px 20px;
margin: -20px 0 0 0;
}
#header,#pagefooter,#container {
margin: 0 auto;
width: 85%;
}
#outerWrap {
float: left;
width: 100%;
margin-left: -200px;
}
#innerWrap {
margin-left: 200px;
}
#left {
float: left;
width: 40%;
}
#content {
float: right;
width: 59.5%  /*不设置60%,为了防止换行*/
}
#content img {
float: right;
}
#side {
float: right;
width: 200px;
}
#pagefooter {
clear: both;
}
</style>
</head>
<body>
<div id="header">
<div class="rounded">
<h2>页头</h2>
<div class="main">
<p>锄禾日当午,汗滴禾下土</p>
</div>
<div class="footer">
<p></p>
</div>
</div>
</div>
<div id="container">
<div id="outerWrap">
<div id="innerWrap">
<div id="left">
<div class="rounded">
<h2>正文</h2>
<div class="main">
<p>
锄禾日当午,汗滴禾下土<br/>
锄禾日当午,汗滴禾下土
</p>
<div class="footer">
<p>
查看详细信息>>
</p>
</div>
</div>
</div>
</div>
<div id="content">
<div class="rounded">
<h2>正文</h2>
<div class="main">
<p>
锄禾日当午,汗滴禾下土
</p>
</div>
<div class="footer">
<p>
查看详细信息>>
</p>
</div>
</div>
</div>
</div>
</div>
<div id="side">
<div class="round">
<h2>正文2</h2>
<div class="main">
<p>
锄禾日当午,汗滴禾下土<br/>
锄禾日当午,汗滴禾下土
</p>
</div>
<div class="footer">
<p>
查看详细信息>>
</p>
</div>
</div>
</div>
</div>
<div id="pagefooter">
<div class="rounded">
<h2>页脚</h2>
<div class="main">
<p>
锄禾日当午,汗滴禾下土
</p>
</div>
<div class="footer">
<p>
</p>
</div>
</div>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  布局 css布局