align-content属性起作用的条件:
对父元素设置自由盒属性display:flex;
并且设置排列方式为横向排列flex-direction:row; (默认值)
设置换行,flex-wrap:wrap;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>align-content属性</title>
<style>
.box {
width: 200px;
display: flex;
/*
flex-direction: row;
flex-wrap: wrap;
*/
flex-flow: row wrap;
/*
默认值为:stretch
align-content:可以取的值有 flex-start,
flex-end,center,space-around,space-between,stretch
*/
align-content: stretch;
height: 300px;
background-color: grey;
}
.box1 {
height: 30px;
width: 100px;
background-color: orange;
}
.box2 {
height: 50px;
width: 200px;
background-color: red;
}
.box3 {
height: 30px;
width: 100px;
background-color: #08a9b5;
}
</style>
</head>
<body>
<div class="box">
<div class="box1">box1</div>
<div class="box2">box2</div>
<div class="box3">box3</div>
</div>
</body>
</html>
flex布局中的align-content属性
最新推荐文章于 2024-04-08 14:40:22 发布