Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移动端 1px 边框推荐解决方案 #839

Open
SoloJiang opened this issue Sep 29, 2021 · 0 comments
Open

移动端 1px 边框推荐解决方案 #839

SoloJiang opened this issue Sep 29, 2021 · 0 comments
Labels

Comments

@SoloJiang
Copy link
Contributor

SoloJiang commented Sep 29, 2021

日常开发中,开发者经常会遇到需要绘制 1px 边框的诉求,由于 Rax App 提供了 rpx 能力,同时为了避免 1px 边框过粗,一般来说符合直觉的写法是:

.box {
  border: 1rpx solid #ddd;
}

但由于移动端不同机型的绘制逻辑不一样,会在某些机型上出现 1rpx 边框消失的问题,所以如下给出移动端通过伪元素绘制 1px 边框最佳实践:

.box {
  position: relative;
  &:after {
     content: " ";
     position: absolute;
     top: 0;
     left: 0;
     width: 200%;
     height: 200%;
     transform: scale(0.5);
     transform-origin: left top;
     box-sizing: border-box;
     border: 1px solid #ddd;
  }
}
@SoloJiang SoloJiang added the Wiki label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant