search

Home  >  Q&A  >  body text

css - weui 用伪元素生成border,源码有点不理解

    
.weui_actionsheet_cell {
  position: relative;
  padding: 10px 0;
  text-align: center;
  font-size: 18px;
}
.weui_actionsheet_cell:before {
      content: " ";
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      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);
}

我想知道为什么weui中,利用伪元素生成border,同时使用了border:1px和height:1px;,然后又在Y轴上缩放0.5倍。我觉得直接用border不久可以了,应该没有那个浏览器不支持border的吧。
巴扎黑巴扎黑2778 days ago944

reply all(5)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:46:02

    In order to adapt to the 1px border problem of high-definition screens and retina screens. Use transform scale y to solve it in one go. The advantage of using pseudo-elements is that there are no more useless p tags.

    reply
    0
  • 阿神

    阿神2017-04-17 11:46:02

    If there is only width but no height, the height should be given here just for better display~to avoid the situation that it cannot be displayed~~This should be for the border width of 1px, first give the height of 1px, and then give Scale the Y axis back ~ it should be a line in the end.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:46:02

    In order to solve the 1px border problem of retina screen

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:46:02

    Don’t talk, look at the pictures

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:46:02

    To achieve 0.5px border

    reply
    0
  • Cancelreply