One pixel problem on the moving side

Source: Internet
Author: User

Recently I found a pixel in the mobile side will have a bug, why? I found that at the time of testing, a pixel-wide border of a phone of different sizes changes with the screen. Although not a big problem, but I found the interview will also ask, so I looked up some answers to summarize.

  1. You can do this by scaling down the scale in the transform:
    . border-bottom{    position:relative;    Border-top:none!important;}. Border-bottom::after {    content: "";    Position:absolute;    left:0;    bottom:0;    width:100%;    height:1px;    Background-color: #e4e4e4;    -webkit-transform-origin:left Bottom;    Transform-origin:left Bottom;}

    Then through the media query

    /* Twice times screen */@media only screens and (-webkit-min-device-pixel-ratio:2.0) {    . border-bottom::after {        - Webkit-transform:scaley (0.5);        Transform:scaley (0.5);    }} /* 3 times times screen */@media only screens and (-webkit-min-device-pixel-ratio:3.0) {    . border-bottom::after {        - Webkit-transform:scaley (0.33);        Transform:scaley (0.33);    }}

    is actually a block-level element of a pixel's height.

  2. The second approach is simple, using a single pixel image instead.
    . border-image-1px {    border-width:1px 0px;    -webkit-border-image:url ("# #") 2 0 stretch;}

One pixel problem on the moving side

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.