1.弹性盒模型
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#div1{
height: 300px;
background: #eeeeee;
display: flex;
}
#div2{
width: 200px;
height: 300px;
background: red;
}
#div3{
flex: 1;
height: 300px;
background: blue;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2"></div>
<div id="div3"></div>
</div>
</body>
</html>
2.浮动
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#div1{
height: 300px;
background: #eeeeee;
}
#div2{
float: left;
width: 200px;
height: 300px;
background: red;
}
#div3{
margin-left:200px;
height: 300px;
background: blue;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2"></div>
<div id="div3"></div>
</div>
</body>
</html>
3.定位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#div1{
height: 300px;
background: #eeeeee;
position: relative;
}
#div2{
width: 200px;
height: 300px;
background: red;
position: absolute;
}
#div3{
background: blue;
height: 300px;
margin-left:200px;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2"></div>
<div id="div3"></div>
</div>
</body>
</html>
4.用margin调
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#div1{
height: 300px;
background: #eeeeee;
}
#div2{
width: 200px;
height: 300px;
background: red;
}
#div3{
background: blue;
height: 300px;
margin-top:-300px;
margin-left:200px;
}
</style>
</head>
<body>
<div id="div1">
<div id="div2"></div>
<div id="div3"></div>
</div>
</body>
</html>
主要的就这四种,如果还有别的好的方法希望大家留言哦