久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

您的位置:首頁技術(shù)文章
文章詳情頁

css3 - css flex 子元素居中

瀏覽:136日期:2023-06-28 09:36:16

問題描述

css3 - css flex 子元素居中

明顯黃色小標(biāo)標(biāo)沒有在中間

<style> .box1 {display: flex;width: 300px;height:300px;background: #dedede;border-radius: 5px;padding: 10px;margin: 10px; } .item1 {width: 50px;height: 50px;background: orange;border-radius: 3px; } .item1:nth-child(2) {align-self: center; }</style><p class='box1'> <span class='item1'></span> <span class='item1'></span></p>

我怎么換方向 怎么調(diào)都沒有真正的居中,怎么去布局它呢?

問題解答

回答1:

你可以先查下手冊 align-self: center 是彈性盒子元素在該行的側(cè)軸(縱軸)上居中放置。

水平居中的是justify-content:center

==================以下更新=========================

justify-content:center 是應(yīng)用在容器上的,你想實(shí)現(xiàn)一個在開始位置,然后一個居中,那就自己實(shí)現(xiàn),比如默認(rèn)容器上 justify-content:flex-start 然后

.item1:nth-child(2) { margin-left: calc(50% - 75px); /* 75px 是第一個盒子的寬度加上自身寬度的一半 */}回答2:

基本是從書和教程抄的,你看看哪個適合你。

1css3 - css flex 子元素居中

.flex-container { padding: 0; margin: 0; list-style: none; /* 定義流動方向,包裝項(xiàng)目 *記住這是相同的: * flex-direction:row; * flex-wrap:wrap; */ display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex; /* 分配剩余空間 */ -webkit-flex-flow: row wrap; justify-content: space-around; }.flex-item { background: black; padding: 2px; width: 100px; height: 100px; margin-top: 10px;}

2css3 - css flex 子元素居中HTML:

<p class='flex-container'> <p></p> <p></p> <p></p> </p>

CSS:

* { margin: 0; padding: 0;}.flex-container { width: 960px; margin: 20px auto; min-height: 300px; font-weight: bold; display: -webkit-flex; display: flex; -webkit-flex-flow: row nowrap; flex-flow: row nowrap; -webkit-justify-content: space-around; justify-content: space-around; -webkit-align-items: stretch; align-items: stretch}.flex-container>p { padding: 10px}.flex-container>p:nth-child(1) { background-color: #e4f1e4; -webkit-flex: 1; flex: 1}.flex-container>p:nth-child(2) { background-color: #d2d4eb; -webkit-flex: 1; flex: 1}.flex-container>p:nth-child(3) { background-color: #f9e7e9; -webkit-flex: 1; flex: 1}回答3:

我改了一下題主的代碼、不知道題主是不是要這種效果

<style>.box1 { display: flex; width: 300px; height:300px; background: #dedede; border-radius: 5px; padding: 10px; margin: 10px; justify-content:center;} .item1 { width: 50px; height: 50px; background: orange; border-radius: 3px;}.item1{ align-self: center;} </style><p class='box1'><span class='item1'></span> </p>

標(biāo)簽: CSS
相關(guān)文章:
主站蜘蛛池模板: 在线观看精品91福利 | 97爱爱视频 | 99re视频在线播放 | 伊人色综合久久天天五月婷 | av女人的天堂 | 国产成人高清 | 91佛爷在线观看 | 免费一区在线 | 五月天婷婷国产精品 | 日日日日干干干干 | 欧美午夜精品久久久久免费视 | 国产精品夜色一区二区三区 | 亚洲免费综合 | 久久av一区二区三区 | 日韩欧美综合在线 | 欧美亚洲一区 | 久久久久国产 | 中文字幕国产视频 | 在线欧美色 | 欧美色综合一区二区三区 | 欧美在线不卡 | 一区二区亚洲 | 在线干 | 久久九九这里只有精品 | 精品亚洲一区二区 | 中文字幕一区二区三区在线视频 | 日韩精品一区二区三区老鸭窝 | 丁香婷婷久久久综合精品国产 | 久久性 | av天天干 | 日韩视频中文字幕 | 在线观看免费毛片视频 | 亚洲国产成人av好男人在线观看 | 欧美久久成人 | 国产精品久久久久婷婷二区次 | 91精品国产一区二区三区蜜臀 | 成人亚洲精品久久久久软件 | 亚洲一一在线 | 成人午夜免费视频 | 综合天天| 国产欧美久久一区二区三区 |