国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

css3 - css flex 子元素居中

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

問題描述

css3 - css flex 子元素居中

明顯黃色小標標沒有在中間

<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>

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

問題解答

回答1:

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

水平居中的是justify-content:center

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

justify-content:center 是應用在容器上的,你想實現一個在開始位置,然后一個居中,那就自己實現,比如默認容器上 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; /* 定義流動方向,包裝項目 *記住這是相同的: * 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>

標簽: CSS
相關文章:
主站蜘蛛池模板: 午夜欧美日韩在线视频播放 | 亚洲国产精品免费在线观看 | 一级大黄美女免费播放 | 亚洲高清不卡 | 精品高清国产a毛片 | 99re66热这里只有精品免费观看 | 亚洲免费网址 | 国产成人午夜精品5599 | 久久免费视屏 | 欧美成人 综合网播九公社 欧美成人26uuu欧美毛片 | 美国毛片毛片全部免费 | 色综合久久88色综合天天小说 | 日本经典在线三级视频 | 久草久草久草 | 99精品福利视频 | 男人的亚洲天堂 | 国产欧美日韩在线视频 | 性欧美视频a毛片在线播放 性欧美一级 | 一级毛片真人免费观看 | 国产成人精品亚洲日本在线观看 | 欧美成人极品怡红院tv | 国产一级片免费看 | 日本一区二区三区在线 视频 | 成年人免费在线视频网站 | 99精品国产成人一区二区 | 美女操穴视频 | 欧美jizzhd精品欧美高清 | 日韩高清在线播放不卡 | 亚洲一区二区成人 | 国产大片中文字幕在线观看 | 精品久久久久不卡无毒 | 国产成 人 综合 亚洲绿色 | 成人在线手机视频 | 亚洲高清自拍 | 亚洲国产最新 | 日本无玛| 国产成人精品视频 | 99免费在线播放99久久免费 | 综合亚洲欧美日韩一区二区 | 草草免费观看视频在线 | 在线亚洲精品自拍 |