css小于1px邊框的實現

1、利用scale


.content h1:after,
        .content h2:after {
            border-top: 9px solid red;
            content: ' ';
            display: block;
            width: 200px;
            position: absolute;
            left: 0;
            bottom: 300px;
            -webkit-transform-origin: left bottom;
        }

        @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);
            }
        }

        @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);
            }
        }

2.devicePixelRatio,對于不同的像素比的屏幕應用不同的圖片
(1)background-size 統一顯示圖片的大小

 -webkit-background-size: 244px 233px;
 -moz-background-size: 244px 233px; 
background-size: 244px 233px

(2)用媒體查詢,min-device-pixel-ratio

<!DOCTYPE html>
<html>
<head>
    <title>測試</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" name="viewport">
    <style type="text/css">
        .sprite-icons-video {
            display: block;
    background-position: -62px -201px;
    width: 22px;
    height: 22px;
}
    .sprite-icons-video{
        background-image: url(icons_7ee46383c7.png);
        background-repeat: no-repeat;
        -webkit-background-size: 244px 233px;
        -moz-background-size: 244px 233px;
        background-size: 244px 233px
    }

@media screen and (-webkit-min-device-pixel-ratio: 1), screen and (min--moz-device-pixel-ratio: 1), screen and (-o-min-device-pixel-ratio: 100/100), screen and (min-device-pixel-ratio: 1), screen and (min-resolution: 1dppx) {
    .sprite-icons-video{
        background-image: url(icons_7ee46383c7.png)
    }
}

@media screen and (-webkit-min-device-pixel-ratio: 2), screen and (min--moz-device-pixel-ratio: 2), screen and (-o-min-device-pixel-ratio: 200/100), screen and (min-device-pixel-ratio: 2), screen and (min-resolution: 2dppx) {
   .sprite-icons-video{
        background-image: url(icons@2x_7ee46383c7.png)
    }
}
    </style>
</head>
<body>
<i class="sprite-icons-video "></i>
</body>
</html>

或者

background-image: -webkit-image-set(url(../images/arrow@2x.png) 2x,
url(../images/arrow@3x.png) 3x);
 background-size: contain;
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容