網(wǎng)站首頁 編程語言 正文
IE10以下完全不兼容flex,IE10部分兼容,使用時對應(yīng)chrome的用法為如下所示:
chrome ? ?IE10
display: flex;? display: -ms-flexbox;
flex-direction: column; -ms-flex-direction: column;
justify-content: center; -ms-flex-pack: center;
justify-content:space-between; -ms-flex-pack: justify;
justify-content:space-around; -ms-flex-pack: justify; // 無法實現(xiàn),用justfiy代替
justify-content: flex-end; -ms-flex-pack: end;
align-items: flex-start; -ms-flex-align: start;
align-items: center; ?? -ms-flex-align: center;
align-items: flex-end; -ms-flex-align: end;
align-items: baseline; -ms-flex-align: baseline;
flex:?1; -ms-flex:?1;
align-self: center; ? -ms-align-self: center;
flex-wrap:?wrap;? -ms-flex-wrap:?wrap;
注:任何的版本的 Internet Explorer (包括 IE8)都不支持屬性值 inherit。
一、常用的flex布局兼容性寫法
//定義flex
.flex{
? ? display: -webkit-flex; ?/* 新版本語法: Chrome 21+ */
? ? display: -webkit-box; ? /* 老版本語法: Safari, iOS, Android browser, older WebKit browsers. */
? ? display: -moz-box; ? ? ?/* 老版本語法: Firefox (buggy) */
? ? display: -ms-flexbox; ? /* 混合版本語法: IE 10 */ ?
? ? display: flex; ? ? ? ? ?/* 新版本語法: Opera 12.1, Firefox 22+ */
}
//主軸為水平方向,起點在左邊
.flex-row {
? -webkit-flex-direction: row;
? -moz-flex-direction: row;
? -ms-flex-direction: row;
? flex-direction: row;
}
//主軸為垂直方向,起點在上沿
.flex-column {
? -webkit-box-direction: normal;
? -webkit-box-orient: vertical;
? -moz-flex-direction: column;
? -webkit-flex-direction: column;
? flex-direction: column;
}
//伸縮寬度
.flex-1 {
? -webkit-flex: 1; ? ? ? ?/* 新版本語法: Chrome 21+ */
? flex: 1; ? ? ? ? ? ? ? ?/* 新版本語法: Opera 12.1, Firefox 22+ */
? -webkit-box-flex: 1; ? ?/* 老版本語法: Safari, iOS, Android browser, older WebKit browsers. */
? -moz-box-flex: 1; ? ? ? /* 老版本語法: Firefox (buggy) */
? -ms-flex: 1; ? ? ? ? ? ?/* 混合版本語法: IE 10 */ ?
}
// 主軸左對齊
.flex-justify-start{
? -webkit-box-pack: start;
? -webkit-justify-content: flex-start;
? -moz-justify-content: flex-start;
? -ms-justify-content: flex-start;
? justify-content: flex-start;
}
// 主軸右對齊
.flex-justify-end{
? -webkit-box-pack: end;
? -webkit-justify-content: flex-end;
? -moz-justify-content: flex-end;
? -ms-justify-content: flex-end;
? justify-content: flex-end;
}
// 主軸居中對齊
.flex-justify-center{
? -webkit-box-pack: center;
? -webkit-justify-content: center;
? -moz-justify-content: center;
? -ms-justify-content: center;
? justify-content: center;
}
// 主軸兩端對齊,項目之間的間隔都相等
.flex-justify-between{
? -webkit-box-pack: justify;
? -webkit-justify-content: space-between;
? -moz-justify-content: space-between;
? -ms-justify-content: space-between;
? justify-content: space-between;
}
// 每個項目兩側(cè)的間隔相等。所以,項目之間的間隔比項目與邊框的間隔大一倍
.flex-justify-around{
? -webkit-box-pack: distribute;
? -webkit-justify-content: space-around;
? -moz-justify-content: space-around;
? -ms-justify-content: space-around;
? justify-content: space-around;
}
// 交叉軸的起點對齊
.flex-align-start{
? -webkit-box-align: start;
? -webkit-align-items: flex-start;
? -moz-align-items: flex-start;
? -ms-align-items: flex-start;
? align-items: flex-start;
}
// 交叉軸的終點對齊
.flex-align-end{
? -webkit-box-align: end;
? -webkit-align-items: flex-end;
? -moz-align-items: flex-end;
? -ms-align-items: flex-end;
? align-items: flex-end;
}
// 交叉軸的中點對齊
.flex-align-center{
? -webkit-box-align: center;
? -webkit-align-items: center;
? -moz-align-items: center;
? -ms-align-items: center;
? align-items: center;
}
// 項目的第一行文字的基線對齊
.flex-align-baseline{
? -webkit-box-align: baseline;
? -webkit-align-items: baseline;
? -moz-align-items: baseline;
? -ms-align-items: baseline;
? align-items: baseline;
}
// (默認(rèn)值):如果項目未設(shè)置高度或設(shè)為auto,將占滿整個容器的高度
.flex-align-stretch{
? -webkit-box-align: stretch;
? -webkit-align-items: stretch;
? -moz-align-items: stretch;
? -ms-align-items: stretch;
? align-items: stretch;
}
// 換行,第一行在上方
.flex-wrap {
? -webkit-box-lines: multiple;
? -webkit-flex-wrap: wrap;
? -moz-flex-wrap: wrap;
? -ms-flex-wrap: wrap;
? -o-flex-wrap: wrap;
? flex-wrap: wrap;
}
二、在IE10瀏覽器中,使用flex布局的常用兼容性代碼:
/*display*/
.display_flex{
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.display_flex > *{
display: block;
}
.display_inline-flex{
display: -webkit-inline-box;
display: -ms-inline-flexbox;
display: -webkit-inline-flex;
display: inline-flex;
}
.display_inline-flex > *{
display: block;
}
/*伸縮流方向*/
.flex-direction_column{
-webkit-box-orient: vertical;
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
}
/*主軸對齊*/
.justify-content_flex-center{
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
}
.justify-content_flex-end{
-webkit-box-pack: end;
-ms-flex-pack: end;
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
.justify-content_flex-justify{
-webkit-box-pack: justify;
-ms-flex-pack: justify;
-webkit-justify-content: space-between;
justify-content: space-between;
}
/*側(cè)軸對齊*/
.align-items_flex-start{
-webkit-box-align: start;
-ms-flex-align: start;
-webkit-align-items: flex-start;
align-items: flex-start;
}
.align-items_flex-end{
-webkit-box-align: end;
-ms-flex-align: end;
-webkit-align-items: flex-end;
align-items: flex-end;
}
.align-items_center{
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.align-items_baseline{
-webkit-box-align: baseline;
-ms-flex-align: baseline;
-webkit-align-items: baseline;
align-items: baseline;
}
/*伸縮性*/
.flex_auto{
-webkit-box-flex: 1;
-ms-flex: auto;
-webkit-flex: auto;
flex: auto;
}
.flex_1{
width: 0;
-webkit-box-flex: 1;
-ms-flex: 1;
-webkit-flex: 1;
flex: 1;
}
/*顯示順序*/
.order_2{
-webkit-box-ordinal-group: 2;
-ms-flex-order: 2;
-webkit-order: 2;
order: 2;
}
.order_3{
-webkit-box-ordinal-group: 3;
-ms-flex-order: 3;
-webkit-order: 3;
order: 3;
}
原文鏈接:https://gaodengwen.blog.csdn.net/article/details/131538959
- 上一篇:沒有了
- 下一篇:沒有了
相關(guān)推薦
- 2023-02-27 Golang設(shè)計模式中抽象工廠模式詳細(xì)講解_Golang
- 2022-05-27 Flutter狀態(tài)管理Bloc之定時器示例_Android
- 2022-12-25 React?useState超詳細(xì)講解用法_React
- 2023-05-30 python中pip無法正確安裝或路徑出錯的解決方案_python
- 2022-10-24 IOS開發(fā)Swift?與?OC相互調(diào)用詳解_IOS
- 2022-08-05 Activity supporting ACTION_VIEW is not exported
- 2022-11-07 Flink?側(cè)流輸出源碼示例解析_服務(wù)器其它
- 2022-07-06 C語言舉例講解轉(zhuǎn)義字符的使用_C 語言
- 欄目分類
-
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支