各位技术大牛,我像请问一下,有没有一种方法(除了position,float)可以将任意不同大小div放在一等同于任意大小div之和的盒子当中(类似于七巧板)。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0px;
padding: 0px;
}
#box {
height: 300px;
width: 700px;
border: 1px solid red;
display: flex;
flex-wrap: wrap;
align-content: stretch;
}
#div1{
width: 200px;
height: 170px;
background-color: aquamarine;
}
#div2{
width: 200px;
height: 110px;
background-color: bisque;
}
#div3{
width: 300px;
height: 300px;
background-color: cadetblue;
}
#div4{
margin-top: -130px;
width: 200px;
height: 130px;
background-color: coral;
}
#div5{
margin-top: -190px;
width: 200px;
height: 190px;
background-color: cornflowerblue;
}
</style>
<title>弹性盒子</title>
</head>
<body>
<div id="box">
<div id="div1">1</div>
<div id="div2">2</div>
<div id="div3">3</div>
<div id="div4">4</div>
<div id="div5">5</div>
</div>
</body>
</html>
以上是我的代码但是需要设置margin才可以实现