美文网首页
移动端1px边框详解

移动端1px边框详解

作者: 北上广_d8bd | 来源:发表于2019-06-17 08:59 被阅读0次

第一种

.b-b {

  position: relative;

}

.b-b:after {

  content: " ";

  position: absolute;

  left: 0;

  bottom: 0;

  right: 0;

  /*height: 1px;*/

  border-top: 1px solid #d9d9d9;

  color: #d9d9d9;

  -webkit-transform-origin: 0 0;

  transform-origin: 0 0;

  -webkit-transform: scaleY(0.5);

  transform: scaleY(0.5);

}

node-sass 和sass-loader(vue)

第二种

@media (-webkit-min-device-pixel-ratio: 1.5),

(min-device-aspect-ratio: 1.5) {

  .border-1px {

    &::after {

      transform: scaleY(0.7); //1.5 * 0.7接近1

    }

  }

}

@media (-webkit-min-device-pixel-ratio: 2),

(min-device-aspect-ratio: 2) {

  .border-1px {

    &::after {

      transform: scaleY(0.5); //2 * 0.5 = 1

    }

  }

}

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

(min-device-aspect-ratio: 2.5) {

  .border-1px {

    &::after {

      transform: scaleY(0.4); //2.5 * 0.4 = 1

    }

  }

}

@media (-webkit-min-device-pixel-ratio: 3),

(min-device-aspect-ratio: 3) {

  .border-1px {

    &::after {

      transform: scaleY(0.333); //3 * 0.333接近 1

    }

  }

}

@media (-webkit-min-device-pixel-ratio: 3.5),

(min-device-aspect-ratio: 3.5) {

  .border-1px {

    &::after {

      transform: scaleY(0.2857); //3.5 * 0.2857接近 1

    }

  }

}

封装

@mixin border($height, $color) {    //封装成的border  height指的是大小,到时候需要定位 加z-index;不然会被遮住 

  position: relative;

  &::after {

    position: absolute;

    display: block;

    left: 0;

    bottom: 0;

    width: 100%;

    height: .78rem;

    border: $height solid $color;

    content: '';

    border-radius: .06rem;

  }

}

@mixin border-bottom($height, $color) {  //封装成的border-bottom

  position: relative;

  &::after {

    position: absolute;

    display: block;

    left: 0;

    bottom: 0;

    width: 100%;

    border-top: $height solid $color;

    content: '';

  }

}

@mixin border-top($height, $color) { // 封装成的border-top

  position: relative;

  &::after {

    position: absolute;

    display: block;

    left: 0;

    top: 0;

    width: 100%;

    border-top: $height solid $color;

    content: '';

  }

}

调用

@include border(1px, #d7d7d7);

第三种

@media (-webkit-min-device-pixel-ratio: 1.5),

(min-device-aspect-ratio: 1.5) {

  .border-1px {

    &::after {

      transform: scaleY(0.7); //1.5 * 0.7接近1

    }

  }

}

@media (-webkit-min-device-pixel-ratio: 2),

(min-device-aspect-ratio: 2) {

  .border-1px {

    &::after {

      transform: scaleY(0.5); //2 * 0.5 = 1

    }

  }

}

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

(min-device-aspect-ratio: 2.5) {

  .border-1px {

    &::after {

      transform: scaleY(0.4); //2.5 * 0.4 = 1

    }

  }

}

@media (-webkit-min-device-pixel-ratio: 3),

(min-device-aspect-ratio: 3) {

  .border-1px {

    &::after {

      transform: scaleY(0.333); //3 * 0.333接近 1

    }

  }

}

@media (-webkit-min-device-pixel-ratio: 3.5),

(min-device-aspect-ratio: 3.5) {

  .border-1px {

    &::after {

      transform: scaleY(0.2857); //3.5 * 0.2857接近 1

    }

  }

}

直接写border 就可以了

相关文章

  • 1px

    CSS中1px分割线处理移动web开发之像素和DPR详解7种方法解决移动端Retina屏幕1px边框问题IOS基础...

  • 前端遇到的那些技术难点及性能优化之css篇

    移动端兼容 css篇 移动端的 1px 问题描述:1px 的边框。在高清屏下,移动端的 1px 会很粗。 产生原因...

  • 移动端适配及1px边框问题

    1、移动端适配 2、1px边框问题

  • 移动端1px边框详解

    第一种 .b-b{ position:relative; } .b-b:after{ content:""; po...

  • 移动端一像素边框

    如何实现在移动端中显示一像素的边框 实现方案一:0.5像素 标准边框语法div{ border: 1px sol...

  • 移动端1像素边框问题

    移动端1像素边框问题: 设置一个div的底部边框为 1px solid #000; 实际表现却是边框线是模糊的,或...

  • 1px边框问题

    问题:ui设计稿中边框为1px,在实际的前端开发,移动端设备中会出现设置border:1px solid #000...

  • 移动端1px边框

  • 移动端1px边框

    为什么1px的边框在移动端上显示会比较粗呢?是因为不同的手机有不同的像素密度。物理像素:设备像素;设备独立像素:c...

  • 常用css总结

    垂直居中 伪类 + transform 实现移动端 Retina 屏幕 1px 边框 flex常用布局盒结构 关于...

网友评论

      本文标题:移动端1px边框详解

      本文链接:https://www.haomeiwen.com/subject/xbdofctx.html