移動端1px解決方案


移動端1px解決方案

設備像素比?

window.devicePixelRatio是設備上物理像素和設備獨立像素(device-independent pixels (dips))的比例。

-webkit-min-device-pixel-ratio的常見值對照

-webkit-min-device-pixel-ratio為1.0

  1. 所有非Retina的Mac
  2. 所有非Retina的iOS設備
  3. Acer Iconia A500 
  4. Samsung Galaxy Tab 10.1
  5. Samsung Galaxy S 

-webkit-min-device-pixel-ratio為1.3

  1. Google Nexus 7

-webkit-min-device-pixel-ratio為1.5

  1. Google Nexus S 
  2. Samsung Galaxy S II 
  3. HTC Desire
  4. HTC Desire HD
  5. HTC Incredible S 
  6. HTC Velocity
  7. HTC Sensation

-webkit-min-device-pixel-ratio為2.0

  1. iPhone 4
  2. iPhone 4S
  3. iPhone 5
  4. iPad (3rd generation)
  5. iPad 4
  6. 所有Retina displays 的MAC
  7. Google Galaxy Nexus
  8. Google Nexus 4
  9. Google Nexus 10
  10. Samsung Galaxy S III
  11. Samsung Galaxy Note II
  12. Sony Xperia S
  13. HTC One X 

實現移動端1px邊框有以下幾種方式:

背景圖漸變

背景圖圖片

js判定支持0.5px

rem解決方案

scale縮放的方式

背景圖漸變

 

 

樣例: 百度糯米

背景圖圖片

 

 

js判定支持0.5px

 

 

rem解決方案

 

 

樣例: 美團

scale縮放的方式(推薦此方式)

 

 

整體實現DEMO

http://10.14.57.140:8022/demo.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM