In a mobile Web project, the following 1-pixel border is often implemented
Mobile Web design, the retina display under the screen will be 1px will be rendered as 2px, then the visual version of 1px lines to restore the page needs CSS defined as 0.5px
But just as we go to use 0.5px to Boder to find the CSS border-width:0.5px does not work, that is not really support 0.5px it?
Some of the problems we found when we defined 0.5px
- The border-width value of the CSS supports. 5px, but the display status is affected by the screen resolution
- iOS 8 and Winphone 8 devices have special handling of the HD screen and support display border-width:.5px
- Android almost all models do not support the display. 5px border
Implement the. 5px Line
There are many methods on the network, such as setting up Viewport,box-shawdow,border-image,background-image,transform:scale and so on, here do not introduce (Baidu or google "Retina 1px border" Has the answer), This article only describes one kind of thought to be more useful method, one is good compatibility, secondly does not depend on the picture.
Transform:scale (x, y)
Through the CSS support to define border or height for. 5px large lines, on Android devices can not be displayed, here is a small trick, the result is set to 1px, and then by Transform:scale (x, y) to scale the line half of the original, can display 0.5px of lines.
<style type= "Text/css" >.line { height:50px; line-height:50px; Background-color: #CCC; border-bottom:1px solid Red} . scale { position:relative; height:50px; line-height:50px; Background-color: #CCC}. scale:after { position:absolute; Content: "; width:100%; left:0; bottom:0; height:1px; background-color:red; -webkit-transform:scale (1,.5); Transform:scale (1,.5); -webkit-transform-origin:center Bottom; Transform-origin:center Bottom}</style><div class= "line" >1px</div><div class= "scale" >0.5px</div>
Mobile webApp-1 pixel Implementation (point 5 pixels secret)