移动端1px边框详解

第一种

.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 就可以了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 一、使用真实手机测试未发布网页的方法 方法① 在虚拟机中搭建xampp,将文件通过FTP传到虚拟机,在一个局域网中...
    fastwe阅读 4,088评论 0 0
  • 1.背景图渐变.ui-border-t { border-top: 1px solid #e0e0e0 }.ui-...
    RiverSouthMan阅读 4,026评论 0 0
  • 关于css常见问题,大多是移动端的。 简单的排版规则:条目与条目之间空两行,每条内容部分分段空一行。标点符号全部用...
    苏水儿阅读 10,491评论 0 9
  • 有一段时间没有跑山,其实普通跑步也有好长时间没有过了。 五点半起床,纠结斗争好久才换好了衣服,出门时已经六点出头。...
    天香后街阅读 2,682评论 0 0
  • 曾经伤心知为谁 尔今未知侬心醉 独自沉醉偷洒泪 只待他日把缘随 尔今着迷只为奇 未知侬今心早醉 君若急待侬快醒 何...
    逸而全真阅读 1,558评论 0 2

友情链接更多精彩内容