原理:子 div 以 relative 的方式浮动在父 div 上方。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DIV 浮动</title>
<style>
.below {
position: absolute;
width: 200px;
height: 200px;
border: 1px solid #000;
background: #999;
}
.above {
position: relative;
width: 100px;
height: 100px;
border: 1px solid #F00;
background: #FFF;
z-index: 1;
}
</style>
</head>
<body>
<div>
<div class="below">
我浮动在下面,你只能看到这些
</div>
<div class="above">
我浮动在上面
</div>
</body>
</html>

网友评论