利用伪类清楚浮动:
代码:
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>haha</title>
<style>
.left{
float: left;
}
.clearfix:after{
content:'.';
clear: both;
display: block;
visibility: hidden;
height:0;
}
</style>
</head>
<body>
<divstyle="background-color: red"class="clearfix">
<divclass="left"style="height:100px;background-color: green">1</div>
<divclass="left">2</div>
</div>
</body>
</html>
效果:
自定义小尖角:
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title></title>
<style>
.icon{
display:inline-block;
border-top:15px solid transparent;
/*transparent 表示透明*/
border-right:15px solid red;
border-bottom:15px solid transparent;
border-left:15px solid transparent;
}
</style>
</head>
<body>
<divclass="icon"></div>
</body>
</html>
后台管理布局一:
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>后台管理布局一</title>
<style>
/*去掉默认的边框*/
body{
margin:0;
}
/*工具栏样式*/
.pg-header{
height:48px;
background-color:#9a9a9a;
}
/*菜单栏样式*/
.pg-body .body-menu{
position: absolute;
top:48px;
left:0;
bottom:0;
width:200px;
background-color:#1abc9c;
}
/*内容样式*/
.pg-body .body-content{
position: absolute;
top:48px;
left:200px;
right:0;
background-color:#8a6d3b;
/*bottom: 0;*/
/*overflow: auto;*/
}
</style>
</head>
<body>
<divclass="pg-header"></div>
<divclass="pg-body">
<divclass="body-menu"></div>
<divclass="body-content">
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
</div>
</div>
<divclass="pg-footer"></div>
</body>
</html>
后台管理布局二:
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>后台管理布局二</title>
<style>
body{
margin:0;
}
.pg-header{
height:48px;
background-color:#2459a2;
}
.pg-body .body-menu{
position: absolute;
top:48px;
left:0;
bottom:0;
width:200px;
background-color: red;
}
.pg-body .body-content{
position: absolute;
top:48px;
left:210px;
right:0;
background-color: green;
bottom:0;
overflow:auto;
}
</style>
</head>
<body>
<divclass="pg-header"></div>
<divclass="pg-body">
<divclass="body-menu"></div>
<divclass="body-content">
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>xiaoyao<br/>
</div>
</div>
<divclass="pg-footer"></div>
</body>
</html>
从上面两个例子可以体会
bottom: 0;
overflow: auto;
同时使用的效果。