flex-wrap 换行
flex-wrap
主要通过在外层容器中设置它里面的子项目是否可以换行。认情况下项目是不换行的。
flex-wrap 规定flex容器是单行或者多行,同时横轴的方向决定了新行堆叠的方向。
认情况下,设置了 display:flex
的容器是不会换行的,这时候如果我们希望它换行就可以通过 flex-wrap
设置超出宽度换行,也可以设置它如何换行,既换行之后的排列的方向。
flex-wrap: rap|wrap|wrap-reverse|initial|inherit;
值
.demo{
display: flex;
flex-wrap: wrap;
}
.item{
width: px;
height: px;
line-height: px;
background: #ccc;
border-right: px solid #fff;
text-align: center;
}
图
<!DOCTYPE html>
<html lang="en">
<head>
< charset="UTF-8">
< name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.demo{
display: flex;
flex-wrap: wrap;
}
.item{
width: px;
height: px;
line-height: px;
background: #ccc;
border-right: px solid #fff;
text-align: center;
}
</style>
</head>
<body>
<div class="demo">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
</body>
</html>
.demo{
display: flex;
flex-wrap: wrap-reverse;
}
.item{
width: px;
height: px;
line-height: px;
background: #ccc;
border-right: px solid #fff;
text-align: center;
}
图
<!DOCTYPE html>
<html lang="en">
<head>
< charset="UTF-8">
< name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.demo{
display: flex;
flex-wrap: wrap-reverse;
}
.item{
width: px;
height: px;
line-height: px;
background: #ccc;
border-right: px solid #fff;
text-align: center;
}
</style>
</head>
<body>
<div class="demo">
<div class="item">1</div>
<div class="item">2</div>
<div class="item">3</div>
<div class="item">4</div>
</div>
</body>
</html>
flex
弹性盒模型认是不换行的既 rap