css display:flex佈局
阿新 • • 發佈:2021-01-23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>flex layout</title>
<style>
.container {
height: 300px;
width: 700px;
padding: 10px;
border: 2px solid #f0eded;
/* 建立一個flex佈局容器 */
display: flex;
/* flex-direction: row; */
/* flex-wrap: wrap; */
/* 等同於flex-direction: row; flex-wrap: wrap; */
flex-flow : row wrap;
/* 列間距 */
column-gap: 5px;
/* 行間距 */
row-gap: 10px;
/* 水平對齊方式 */
justify-content: center;
/* 垂直對齊方式 */
align-items: center;
}
.item {
box-shadow: 0 0 3px #cccccc;
text-align : center;
color: #cccccc;
width: 100px;
height: 100px;
/* margin: auto; */
}
</style>
</head>
<body>
<div class="container">
<div class="item item1">A</div>
<div class="item item2">B</div>
<div class="item item3">C</div>
<div class="item item4">D</div>
<div class="item item5">E</div>
<div class="item item6">F</div>
</div>
</body>
</html>