z-memo / interview

我们缺的从来都不是前端/后端工程师,而是工程师(或者那些会系统思考,并总是想着解决问题的人)
27 stars 3 forks source link

如何解决移动端 Retina 屏 1px 像素问题 ? #93

Open MrSeaWave opened 3 years ago

MrSeaWave commented 3 years ago

参考 https://github.com/Advanced-Frontend/Daily-Interview-Question/issues/513#issuecomment-883756172

image

MrSeaWave commented 3 years ago

https://juejin.cn/post/6844903877947424782#heading-13

MrSeaWave commented 2 years ago

伪元素 + transform


@mixin onepx($positions: top right bottom left, $border-color: #ddd, $border-radius: 0) {
  &:after {
    content: '';
    pointer-events: none;
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    border-width: 0;
    border-radius: $border-radius;
    @each $position in $positions {
      border-#{$position}: 1px solid $border-color;
    }

    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
      width: 200%;
      height: 200%;
      transform: scale(0.5);
      transform-origin: 0 0;
      border-radius: $border-radius * 2;
    }
  }
}