HTML/Html-Css/20-flex布局-2.html
2023-05-01 19:37:40 +08:00

83 lines
2.1 KiB
HTML

<!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>flex</title>
<style>
#app {
/* 变flex容器 */
display: flex;
height: 200px;
width: 300px;
background-color: lightcoral;
/* 水平轴的方向控制 */
flex-direction: row;
/* 正常轴 左右 */
/* flex-direction: row-reverse; */
/* 右左 */
/* flex-direction: column; */
/* 上下 */
/* flex-direction: column-reverse; */
/* 下上 */
/* 如果项目在容器中挤不下,它也不会换行 */
/* flex-wrap: wrap; */
/* 换行 */
/* flex-wrap: nowrap; */
/* 不换行 */
/* 主轴对齐方式 */
/* justify-content: flex-start; */
/* 开始方向对齐 */
/* justify-content: flex-end; */
/* 结束方向对齐 */
/* justify-content:space-around ; */
/* 空余空间平均分配 */
/* justify-content: space-between; */
/* 两边靠边其余空间平均分配 */
/* 垂直交叉轴对齐方式 */
/* align-items: center; */
/* 居中 */
/* align-items: flex-start; */
/* 开始对齐 */
/* align-items: flex-end; */
/* 结束对齐 */
/* align-items: baseline; */
/* 文字基于一条线对齐 */
/* align-items: stretch; */
/* 其他标签 */
}
.box {
background-color: lightgreen;
width: 100px;
height: 100px;
}
</style>
</head>
<body>
<div id="app">
<div class="box"><span>1</span></div>
<div class="box" style="height: 150px; font-size: 30px;">2</div>
<div class="box">3</div>
<div class="box">4</div>
</div>
</body>
</html>