前端學習筆記-8.7.2移動端一畫素
1畫素:
步驟一:新建base.styl的檔案, 步驟二:新建index.styl,把base.styl的檔案放在裡面 步驟三:在main.js引入即可全域性使用 為什麼需要一畫素,看下邊: DIPs指裝置獨立畫素(DPI指每英寸點的個數) 非視網膜螢幕的iphone手機上,螢幕物理畫素320px,獨立畫素也是320px,因此,min-device-pixel-ratio:1。
而對於視網膜螢幕的iphone,如iphone4s,縱向顯示的時候,螢幕物理畫素640px。當設定<meta name="viewport" content="width=device-width">
的時候,其視區寬度並不是640px,而是320px,這是為了有更好的閱讀體驗-更合適的文字大小。
這樣,在視網膜螢幕的iphone上,螢幕物理畫素640px,獨立畫素還320px,因此min-device-pixel-radio: 2。
所以當開發在考慮相容性的時候,會將css屬性設定成:(ios) //ios @media (-webkit-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio:1.5) .border-1px &::after -webkit-transform : scaleY(0.7) transform: scaleY(0.7)
@media (-webkit-min-device-pixel-ratio: 2),(min-device-pixel-radio: 2) .border-1px &::after -webkit-transform: scaleY(0.5) transform: scaleY(0.5) //android-opera @media (-webkit-min-device-pixel-ratio: 2.25),(min-device-pixel-radio: 2.25) .border-1px &::after -webkit-transform: scaleY(0.5) transform: scaleY(0.5) (採用之前資料,僅參考)