日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

flex.css快速入门,极速布局

發布時間:2023/12/2 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 flex.css快速入门,极速布局 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

什么是flex.css?

css3 flex 布局相信很多人已經聽說過甚至已經在開發中使用過它,但是我想我們都會有一個共同的經歷,面對它的各種版本,各種坑,傻傻的分不清楚,flex.css就是對flex布局的一種封裝,通過簡潔的屬性設置就能使得它完美的運行在移動端的各種瀏覽器,甚至能運行在ie10 的各種PC端瀏覽器中。它天然的能夠很好的將頁面布局和css進行分離,讓css專注于元素的顯示效果,我稱之為聲明式布局......


flex和data-flex

flex.css 有兩個版本,一個是flex.css一個是data-flex.css,這兩個版本其實是一樣的,唯一的區別是,一個是使用flex屬性設置,一個是使用data-flex屬性設置。react 不支持flex屬性直接布局,所以data-flex.css實際上是為了react而誕生的


安裝flex.css

官方地址:https://github.com/lzxb/flex.css

通過npm安裝:

npm install --save flex.css

本例子教程例子,則是從官方項目下載下來后,解壓出來后,將dist目錄下的flex.css文件引入使用


Hello world

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>Hello world</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}</style> </head><body><div class="box" flex>Hello world</div> </body></html>


設置主軸方向

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>設置主軸方向</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}.item {width: 30px;height: 30px;line-height: 30px;color: #fff;text-align: center;}</style> </head><body><h2>從上到下</h2><div class="box" flex="dir:top"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>從右到左</h2><div class="box" flex="dir:right"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>從下到上</h2><div class="box" flex="dir:bottom"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>從左到右(默認)</h2><div class="box" flex="dir:left"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div> </body></html>


主軸對齊方式

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>主軸對齊方式</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}.item {width: 30px;height: 30px;line-height: 30px;color: #fff;text-align: center;}</style> </head><body><h2>從右到左</h2><div class="box" flex="main:right"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>從左到右(默認)</h2><div class="box" flex="main:left"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>兩端對齊</h2><div class="box" flex="main:justify"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>居中對齊</h2><div class="box" flex="main:center"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div> </body></html>


交叉軸對齊方式

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>交叉軸對齊方式</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}.item {width: 30px;/*height: 30px;*/line-height: 30px;color: #fff;text-align: center;}</style> </head><body><h2>從上到下(默認)</h2><div class="box" flex="cross:top"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>從下到上</h2><div class="box" flex="cross:bottom"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>基線對齊</h2><div class="box" flex="cross:baseline"><div class="item" style="font-size: 30px; background: red;">1</div><div class="item" style="font-size: 12px; background: blue;">2</div><div class="item" style="font-size: 40px; background: #000;">3</div></div><h2>居中對齊</h2><div class="box" flex="cross:center"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>高度并排鋪滿</h2><div class="box" flex="cross:stretch"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div> </body></html>


子元素設置

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>交叉軸對齊方式</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}.item {width: 30px;height: 30px;line-height: 30px;color: #fff;text-align: center;}</style> </head><body><h2>子元素平分空間</h2><div class="box" flex="box:mean"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>第一個子元素不要多余空間,其他子元素平分多余空間</h2><div class="box" flex="box:first"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>最后一個子元素不要多余空間,其他子元素平分多余空間</h2><div class="box" flex="box:last"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div><h2>兩端第一個元素不要多余空間,其他子元素平分多余空間</h2><div class="box" flex="box:justify"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div> </body></html>


flex-box元素剩余空間比例分配

取值范圍(0-10),單獨設置子元素多余空間的如何分配,設置為0,則子元素不占用多余的多余空間

多余空間分配 = 當前flex-box值/子元素的flex-box值相加之和


flex-box實現兩端不需要多余空間,中間占滿剩余空間

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>flex-box實現兩端不需要多余空間,中間占滿剩余空間</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}.item {width: 30px;height: 30px;line-height: 30px;color: #fff;text-align: center;}</style> </head><body><h2>flex-box實現兩端不需要多余空間,中間占滿剩余空間</h2><div class="box" flex><div class="item" flex-box="0" style="background: red;">1</div><div class="item" flex-box="1" style="background: blue;">2</div><div class="item" flex-box="0" style="background: #000;">3</div></div> </body></html>


水平居中

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><title>水平居中</title><link rel="stylesheet" href="./flex.css"><style type="text/css">.box {width: 150px;height: 150px;border: 1px solid #ddd;}.item {width: 30px;height: 30px;line-height: 30px;color: #fff;text-align: center;}</style> </head><body><h2>水平居中</h2><div class="box" flex="main:center cross:center"><div class="item" style="background: red;">1</div><div class="item" style="background: blue;">2</div><div class="item" style="background: #000;">3</div></div> </body></html>

還有更強大的,等待你的發現!


更多專業前端知識,請上 【猿2048】www.mk2048.com

總結

以上是生活随笔為你收集整理的flex.css快速入门,极速布局的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产成人综合久久 | 日本阿v视频在线观看 | av小说天堂网 | 日日日人人人 | 国产乱码精品一区二区三 | 国产精选在线观看 | 国产欧美亚洲一区 | 欧美成人影音 | 性欧美大战久久久久久久久 | 亚洲二区一区 | 久久久成人网 | 精品网站| 少妇脚交调教玩男人的视频 | 色综合久久中文字幕无码 | 成人羞羞国产免费 | 在线免费视频你懂的 | 亚洲乱视频 | 欧美大片黄 | 99re在线精品 | 理论片琪琪午夜电影 | 亚洲综合在线五月 | 献给魔王伊伏洛基亚吧动漫在线观看 | av青青 | 超碰在线97观看 | 91成人网页 | 黄色最新网址 | 老牛影视av一区二区在线观看 | 四虎综合网| 一级二级三级视频 | 少妇裸体淫交视频免费看高清 | 日韩精品免费一区 | www.999av | 久久99久久99精品免观看软件 | 男人的天堂日韩 | 2025国产精品视频 | 精品成人av一区二区在线播放 | 亚洲 国产 欧美 日韩 | 一级成人免费视频 | 97视频免费 | 一级大片黄色 | 亚洲区自拍偷拍 | 天堂va蜜桃一区 | 国产做爰xxxⅹ久久久精华液 | v8888av| 免费在线观看的av | 国产91福利 | 男欢女爱久石 | 区一区二在线观看 | 国产精品一区二区网站 | 国产精品51麻豆cm传媒 | 自拍偷拍福利视频 | 国产小视频免费 | 久久综合99 | 中文字幕7 | 成人区一区二区 | 日本久热 | 草久在线观看视频 | 欧美激情喷水 | 国产亚洲精品自拍 | 日韩欧| av一级免费 | 日本精品一二三区 | 狠狠狠狠狠狠狠干 | 日韩精品一区二区三区无码专区 | 超碰免费97 | 日本亲子乱子伦xxxx50路 | 善良的女朋友在线观看 | 裸体女人a级一片 | 国产精品极品白嫩 | 极品熟妇大蝴蝶20p 国产偷自拍视频 | 超碰免费公开 | 久久艹国产精品 | 成人午夜免费电影 | 8mav在线 | 欧美精品第二页 | 欧美福利在线观看 | 久久国产麻豆 | 在线免费观看一区 | 久久久久久久久久久网 | 99久久久无码国产精品不卡 | 成年人福利网站 | 国产经典三级在线 | a午夜| 亚洲 美腿 欧美 偷拍 | 日本一二区视频 | 福利视频午夜 | 嫩模被强到高潮呻吟不断 | 各处沟厕大尺度偷拍女厕嘘嘘 | 午夜精品久久久久久久四虎美女版 | 调教亲女小嫩苞h文小说 | 中国国语农村大片 | 免费看黄色的视频 | 狠狠躁18三区二区一区视频 | 中文字幕在线观看视频一区二区 | 亚洲av无码一区二区三区dv | 久草新视频 | 极品少妇视频 | 亚洲精品无码久久久久久久 | 亚洲女人久久久 |