<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div class="father">
<div class="left"></div>
<div class="right"></div>
</div>
</body>
<style lang="css">
/* 1. float */
/* .left {
width: 200px;
height: 200px;
float: left;
background-color: blue;
}
.right {
height: 200px;
margin-left: 200px;
background-color: red;
} */
/* 2.通过绝对定位 */
.father {
position: relative;
height: 200px;
}
.left {
position: absolute;
float: left;
width: 200px;
height: 100%;
background-color: blue;
}
.right {
position: absolute;
left: 200px;
right: 0;
height: 100%;
background-color: red;
}
/* 3.flex 布局 */
/* .father {
height: 200px;
display: flex;
}
.left {
width: 200px;
height: 100%;
background-color: blue;
}
.right {
flex: 1;
height: 100%;
background-color: red;
} */
</style>
</html>
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.youkuaiyun.com/Jet_Lover/article/details/115646489