移动端1px边框的解决方案

因为设备像素比不同,边框的大小在不同的设备上也不同

border-1px($color)
  position: relative
  &:after
    display: block
    position: absolute
    left: 0
    bottom: 0
    width: 100%
    border-bottom: 1px solid $color
    content: ' '

@media (-webkit-min-device-pixel-ratio: 1.5),(min-device-pixel-ratio: 1.5)
  .border-1px
    &::after
      -webkit-transform: scaleY(0.7)
      transform: scaleY(0.7)
@media (-webkit-min-device-pixel-ratio: 2),(min-device-pixel-ratio: 2)
  .border-1px
    &::after
      -webkit-transform: scaleY(0.5)
      transform: scaleY(0.5)
主要代码是给一个元素添加一个伪类 内容为空 然后在media里面根据缩放比例更改scaleY 边框的大小=scalyY*缩放比例
由于最近用到的是stylus 语法上与style有些不同 各位可适当参考 

猜你喜欢

转载自blog.csdn.net/qq2806000829/article/details/75500883