Mobile webApp-1 pixel Implementation (point 5 pixels secret)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.