国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > Flex > 正文

CSS中display flex整理(布局利器)

2024-09-08 18:17:13
字體:
來源:轉載
供稿:網友

關于display:flex布局,有人了解頗深,我也是看著別人的東西學習的。

display:flex的布局是什么、基本概念之類的我根本就不了解,只會用。每次看到概念之類的東西,我都是掃一眼就過去。

第一個屬性和用法:flex-direction

我了解的方法有4個:row(水平排列)、row-revese(水平反向排列)、column(垂直排列)、column-reserve(垂直反向排列)

 


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="width:300px;border:1px solid red;display: flex;flex-direction: row;">
<div style="width: 100px;height: 100px;background-color: black;"></div>
<div style="width: 100px;height: 100px;background-color: green;"></div>
<div style="width: 100px;height: 100px;background-color: yellow;"></div>
<div style="width: 100px;height: 100px;background-color: blue;"></div>
</div>
</body>
</html>

上面的代碼和效果圖是屬性為row時的效果

注意:雖然是設置好的寬度,但是父容器只有300px,子div沒法達到100px,而是適應父容器

只需要將 flex-direction: row代碼替換成flex-direction:row-revese 或者flex-direction:column 或則flex-direction:column-reserve,就可以得到不同的效果

下面是效果圖:

row-revese

——-

column

——-

column-reverse

——-

第二個屬性和用法:flex-wrap

這是換行屬性:nowrap(不換行)、wrap(換行)、wrap-reverse(方向換行)

 


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="width:300px;border:1px solid red;display: flex;flex-wrap: wrap;">
<div style="width: 100px;height: 100px;background-color: black;"></div>
<div style="width: 100px;height: 100px;background-color: green;"></div>
<div style="width: 100px;height: 100px;background-color: yellow;"></div>
<div style="width: 100px;height: 100px;background-color: blue;"></div>
</div>
</body>
</html>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 湾仔区| 和顺县| 迭部县| 南丰县| 屯门区| 兴国县| 平谷区| 临夏市| 昌黎县| 偏关县| 牡丹江市| 邵武市| 重庆市| 二连浩特市| 开远市| 资阳市| 浠水县| 扎兰屯市| 河西区| 永新县| 昭通市| 东丰县| 百色市| 庆安县| 威信县| 民勤县| 安溪县| 无锡市| 禹州市| 屯昌县| 苗栗市| 广灵县| 阿拉善左旗| 舒兰市| 榆社县| 大余县| 始兴县| 荔波县| 科技| 廊坊市| 南平市|