flexbox子盒子align-self属性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.flex-container {
display: flex;
width: 700px;
height: 400px;
background-color: gray;
}
.flex-item {
background-color: green;
width: 100px;
height: 100px;
margin: 5px;
}
/*align-self设置子盒子的排列方式,其属性值和父盒子的align-items的相同*/
.flex-item:nth-child(1) {
align-self: flex-start;
}
.flex-item:nth-child(2) {
align-self: center;
}
.flex-item:nth-child(3) {
align-self: flex-end;
}
/*默认值*/
.flex-item:nth-child(4) {
height: auto;
align-self: stretch;
}
/*基线对齐*/
.flex-item:nth-child(5) {
align-self: baseline;
}
.flex-item:nth-child(6) {
font-size: 30px;
align-self: baseline;
}
</style>
</head>
<body>
<div class="flex-container">
<div class="flex-item">flex item 1</div>
<div class="flex-item">flex item 2</div>
<div class="flex-item">flex item 3</div>
<div class="flex-item">flex item 4</div>
<div class="flex-item">baseline</div>
<div class="flex-item">baseline</div>
</div>
</body>
</html>
胖胖熊笔记,笔记已迁移