border设置1px在手机上看起来不止1像素怎么解决啊?

1px边框在2倍屏上为2 “占位”,在3倍屏上为3 “占位”,但是就是想要达到设计图上的1px “占位”效果。

.content h1:after,

.content h2:after {

    border-top: 1px solid #bfbfbf;

    content: ' ';

    display: block;

    width: 100%;

    position: absolute;

    left: 0;

    bottom: 0;

    -webkit-transform-origin: left bottom;

}

/* Retina 适配 */

@media only screen and (-webkit-min-device-pixel-ratio: 2.0),

only screen and (min--moz-device-pixel-ratio: 2.0),

only screen and (-o-min-device-pixel-ratio: 200/100),

only screen and (min-device-pixel-ratio: 2.0) {

    .content h1:after,

    .content h2:after {

        -webkit-transform: scaleY(0.5);

        transform: scaleY(0.5);

    }

}

/* 3倍屏适配 */

@media only screen and (-webkit-min-device-pixel-ratio: 2.5),

only screen and (min--moz-device-pixel-ratio: 2.5),

only screen and (-o-min-device-pixel-ratio: 250/100),

only screen and (min-device-pixel-ratio: 2.5) {

    .content h1:after,

    .content h2:after {

        -webkit-transform: scaleY(0.33333334);

        transform: scaleY(0.33333334);

    }

}

由于高清屏的特性,1px是有2*2个像素点渲染,border 1px在Retina屏下会渲染成2px的边框,实现方式有多种,有图片、阴影、缩放。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 关于css常见问题,大多是移动端的。 简单的排版规则:条目与条目之间空两行,每条内容部分分段空一行。标点符号全部用...
    苏水儿阅读 10,463评论 0 9
  • 1、垂直对齐 如果你用CSS,则你会有困惑:我该怎么垂直对齐容器中的元素?现在,利用CSS3的Transform,...
    kiddings阅读 8,385评论 0 11
  • -:Internet Explorer CSS :- SpecialPurpose _::selection, :...
    弥果阅读 5,127评论 0 1
  • 今天工作进展顺利,所有事情都安排并处理的妥妥的,下午准点下班应邀与朋友聚餐,这一天把我可吃美了,想想就很开心。...
    兰州李慧阅读 1,664评论 1 8
  • 晚上跑步的时候,听青音的节目。聊到婚姻这档事。 听过她几期关于爱情和婚姻的保鲜的观点,觉得观点还算与我相符。爱情和...
    魄心微记录阅读 3,276评论 0 1