如何实现0.5边框

1:用阴影实现,适用于四个边框都存在的情况

box-shadow: 0 0 0 0.5px #18181b;

2: 加一个伪元素,用放大缩小的方式,适用于任何形式的边框

.box {
  position: reative
}
.box::after {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  border-bottom: 1px solid #18181b;
  content: '';
  box-sizing: border-box;
  transform: scale(0.5);
  transform-origin: left top;
}

 

posted @ 2023-06-02 11:16  pyx204  阅读(16)  评论(0)    收藏  举报