要求跟图片一样,颜色也要一样。使用浮动布局来实现跟图片所示的布局页面效果一样
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.big-box{
width: 820px;
height: 620px;
border: 2px solid #c0c4c7;
}
.box-top{
height: 100px;
margin: 10px 10px;
background-color: #52a8d0;
}
.box-center{
height: 380px;
margin: 10px 10px;
}
.box-center-left{
width: 595px;
height: 380px;
background-color: #d24ca4;
float: left;
}
.box-center-right{
width: 195px;
height: 380px;
background-color: #d24ca4;
float: right;
margin-left: 10px;
}
.box-bottom{
height: 100px;
background-color: #54add7;
margin: 0 10px 10px 10px;
}
</style>
</head>
<body>
<div class="big-box">
<div class="box-top"></div>
<div class="box-center">
<div class="box-center-left"></div>
<div class="box-center-right"></div>
</div>
<div class="box-bottom"></div>
</div>
</body>
</html>
效果如下:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
.main {
width: 800px;
height: 600px;
border: 2px solid #c0c4c7;
margin:0px auto;
padding:10px;
}
.top {
height: 100px;
padding:0;
margin:0;
background-color: #52a8d0;
}
.center {
width:100%;
padding:0;
height: 380px;
margin: 10px auto;
}
.center_left {
width: 595px;
height: 380px;
background-color: #d24ca4;
float: left;
}
.center_right {
width: 195px;
height: 380px;
background-color: #d24ca4;
float: right;
margin-left: 10px;
}
.bottom {
clear:both;
height: 100px;
background-color: #54add7;
margin: 0px auto;
}
</style>
</head>
<body>
<div class="main">
<div class="top"></div>
<div class="center">
<div class="center_left"></div>
<div class="center_right"></div>
</div>
<div class="bottom"></div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
*{
padding: 0;
margin: 0;
}
.wrap{
width:800px;
margin:0 auto;
border:1px solid #ccc;
padding:10px;
}
.header{
height: 100px;
background-color: #52a8d0;
}
.container{
height: 380px;
margin:10px 0;
overflow: hidden;
}
.box-center-left{
width: 595px;
height: 380px;
background-color: #d24ca4;
float: left;
}
.box-center-right{
width: 195px;
height: 380px;
background-color: #d24ca4;
float: right;
margin-left: 10px;
}
.footer{
height: 100px;
background-color: #54add7;
}
</style>
</head>
<body>
<div class="wrap">
<div class="header"></div>
<div class="container">
<div class="box-center-left"></div>
<div class="box-center-right"></div>
</div>
<div class="footer"></div>
</div>
</body>
</html>
最关键的记得 clear:both或者设置heigth,清除浮动