久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

css3 - 何時需要 flex-basis: 100% ?

瀏覽:128日期:2023-07-15 09:57:13

問題描述

下面例子中,同樣一個四點骰子為什么.first-face必須有flex-basis: 100%;,而.second-face不需要呢?

codepen地址

/* 核心代碼 */.first-face { display: flex; flex-wrap: wrap; align-content: space-between;}.first-face .column { display: flex; justify-content: space-between; flex-basis: 100%; /* 為什么必須有這一行? */}.second-face { display: flex; justify-content: space-between; /* 這里為什么不需要flex-basis: 100%; ?*/}.second-face .column { display: flex; flex-direction: column; justify-content: space-between;}

問題解答

回答1:

摘錄友站前輩的解答,既簡潔又清晰:

樓主的問題可以歸結為:為什么.second-face 里的.column 會自動占 100%高度,而.first-face 里的.column 卻不會自動占 100%寬度?

我理解是因為 align-items 的缺省值是 stretch (.second-face ),而 flex-grow 缺省值為 0 (.first-face )。

回答2:

因為你的第二個盒子 是 縱向布局 你添加了 flex-direction: column;

而第一個盒子 你又應用了 flex-wrap: wrap; 內容超出后換行 而且用的是 align-content而不是justify-content 內容超出換行后 對齊方式justify-content: space-between不再生效

標簽: CSS
相關文章:
主站蜘蛛池模板: 宜兴市| 房山区| 当涂县| 衢州市| 镇巴县| 屏南县| 盐边县| 许昌市| 翁牛特旗| 五河县| 额敏县| 澄江县| 黄龙县| 潜山县| 文昌市| 商都县| 溆浦县| 湘西| 海阳市| 丁青县| 饶河县| 都昌县| 金门县| 惠州市| 玉溪市| 龙里县| 旺苍县| 和平县| 株洲市| 沂水县| 宣城市| 晋城| 翁牛特旗| 甘谷县| 万山特区| 万年县| 曲麻莱县| 中牟县| 特克斯县| 南漳县| 兴城市|