對於前端工程師來講,不想面對又不得不面對的一個問題就是兼容性。在幾年以前,處理兼容性,通常地就是處理IE低版本瀏覽器的兼容性。而近幾年,隨着移動端的發展,工程師也須要注意手機兼容性了。本文將詳細介紹CSS兼容性前端
【寬高width/height】android
(全兼容) width height (IE6-不支持) min-width max-width min-height max-height
【內邊距padding】ios
padding
【邊框border】web
(全兼容) border border-width border-color border-style (IE8-不支持) border-radius (IE10-不支持) border-image border-image-source border-image-slice border-image-width border-image-outset border-image-repeat (只有firefox支持,須要添加-moz-前綴) border-colors
【外邊距margin】chrome
(全兼容) margin (IE不支持,且須要添加webkit或moz前綴) margin-start margin-end (只有chrome和safari支持,且須要添加webkit前綴) -webkit-margin-before -webkit-margin-after
【輪廓outline】windows
(IE7-不支持) outline outline-width outline-color outline-style (IE不支持) outline-offset
【box-sizing】瀏覽器
[注意]只有firefox支持padding-box屬性值前端工程師
(IE7-不支持)
box-sizing
【display】ide
[注意]IE7-瀏覽器不支持table類屬性值佈局
(全兼容)
display
【浮動】
(全兼容) float clear
【定位】
[注意]IE6-不支持固定定位position:fixed
(全兼容)
position
left
right
top
bottom
z-index
【溢出相關】
(全兼容)
overflow
overflow-x
overflow-y
clip
visibility
(IE不支持)
resize
【flex】
(IE9-不支持) flex-direction flex-wrap flex-flow justify-content align-items align-content align-self flex-basis flex-grow flex-shrink flex order
【多列布局】
(IE10+和chrome瀏覽器支持標準寫法,firefox、safari瀏覽器及移動端android、IOS須要添加前綴) column-width column-count column-gap column-rule column-span(firefox不支持該屬性) columns (只有firefox支持帶前綴的column-fill屬性) column-fill
【grid】
(IE9-不支持,IE10+須要添加-ms-前綴,android4.4.4-不支持,IOS10.2-不支持) grid-template-rows grid-template-columns grid-template-areas grid-column-gap grid-row-gap grid-gap grid-row-start grid-row-end grid-row grid-column-start grid-column-end grid-column grid-area grid-auto-flow grid-auto-rows grid-auto-columns justify-items justify-self align-items align-self
【字體font】
(全兼容) font font-family font-size font-style font-variant font-weight line-height @font-face
【首行縮進text-indent】
(全兼容)
text-indent
【對齊】
[注意]IE7-瀏覽器中vertical-align的百分比值不支持小數行高
(全兼容) text-align vertical-align
(safari瀏覽器、IOS、androis4.4-瀏覽器不支持)
text-align-last
【間隔】
(全兼容) word-spacing letter-spacing
【大小寫text-transform】
(全兼容)
text-transform
【劃線text-decoration】
(全兼容)
text-decoration
【空白符white-space】
[注意]IE7-瀏覽器不支持pre-line和pre-wrap這兩個屬性值
(全兼容)
white-space
【換行】
[注意1]W3C建議使用overflow-wrap替換word-wrap
[注意2]移動端目前基本都不支持word-break的屬性值keep-all
(全兼容) word-wrap
word-break (IE不支持) overflow-wrap
【文本方向】
(全兼容) direction unicode-bidi
(safari和移動端IOS和android須要添加-webkit-前綴;IE瀏覽器只支持本身的私有屬性值) writing-mode
【文本溢出text-overflow】
(全兼容)
text-overflow
【文本陰影text-shadow】
(IE9-不支持)
text-shadow
【背景background】
(全兼容) background background-color background-image background-repeat background-position (IE8-不支持) background-attachment background-clip background-size
【前景和透明度】
(全兼容) color (IE8-不支持) opacity
【顏色模式】
[注意]IE7-不支持color:transparent,但支持background-color: transparent和border-color: transparent
(全兼容) 命名顏色 16進制
RGB
(IE8-不支持) currentColor
RGBA
HSL
HSLA
【光標cursor】
[注意]IE7-不支持拓展樣式
(全兼容)
cursor
【過渡transition】
(IE9-不支持,safari3.1-6、IOS3.2-6.1、android2.1-4.3須要添加-webkit-前綴) transition-property transition-duration transiton-timing-function transition-delay transition
【變形transform】
(IE9-不支持,safari3.1-8、android2.1-4.4.4、IOS3.2-8.4都須要添加前綴) transform transform-origin
transform-style perspective perspective-origin backface-visibility
【漸變gradient】
IE9-不支持,safari4-五、IOS3.2-4.三、android2.1-3只支持線性漸變,且須要添加-webkit-;safari5.1-六、IOS5.1-6.一、android4-4.3支持線性和徑向漸變,且須要添加-webkit-
【動畫animation】
(IE9-不支持;safari4-8、IOS3.2-8.4、android2.1-4.4.4須要添加-webkit-前綴) animation animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-play-state animation-fill-mode
【混合模式】
(IE瀏覽器、android4.4-不支持,safari和IOS須要添加-webkit-前綴) mix-blend-mode background-blend-mode isolation
【濾鏡filter】
(IE瀏覽器及android4.3-瀏覽器不支持,android4.4+須要添加-webkit-前綴) filter
【倒影box-reflect】
只有chrome和safari瀏覽器支持,且須要添加-webkit-前綴
【will-change】
(IE13+、chrome49+、safari9.1+、IOS9.3+、Android52+) will-change
【表格】
(全兼容) border-collapse table-layout caption-side (IE7-不支持) border-spacing empty-cells
【分頁】
(全兼容) page-break-after page-break-before page-break-inside (IE7-不支持) orphans (IE及手機端不支持) windows
【選擇器】
(全兼容) 通配選擇器 * 元素選擇器 div 類選擇器 .box ID選擇器 #box 後代選擇器 div a 分組選擇器 h1,p (IE6-不支持) 屬性選擇器 h1[class] 子元素選擇器 ul > li 相鄰兄弟選擇器 div + p (IE7-不支持) 通用兄弟選擇器 div ~ p
【僞類】
(全兼容) :link :visited (IE6-不支持給<a>之外的其餘元素設置僞類) :hover :active (IE7-不支持) :focus :lang() (IE8-不支持) :target :enabled :disabled :checked :nth-child(n) :nth-last-child(n) :first-child :last-child :only-child :nth-of-type(n) :nth-last-of-type(n) :first-of-type :last-of-type :only-of-type :root :not :empty :target
【僞元素】
(只有當選擇器部分和左大括號之間有空格時,IE6-瀏覽器才支持) :first-letter :first-line (IE7-不支持) :before :after (IE8-不支持) ::selection
【關鍵字】
(IE7-瀏覽器不支持) inherit (IE瀏覽器不支持) initial (IE不支持,safari9-不支持,ios9.2-不支持,android4.4.4-不支持) unset all (只有safari9.1+和ios9.3+支持) revert
【calc】
[注意]android4.4-4.4.4只支持加法和減法。IE9不支持用於backround-position
(IE8-、safari5.1-、ios5.1-、android4.3-不支持) calc
【單位】
(全兼容) px in cm mm q pt pc em ex ch (IE8-不支持) rem (IE8-瀏覽器不支持,IOS7.1-不支持,android4.3-不支持,對於vmax全部IE瀏覽器都不支持) vh vw vmin vmax