移动端1px

写本篇文章的时候是看了 移动端1px问题解决方案 ,这里面介绍了多种解决方案,我本篇文章只着重介绍 伪元素先放大后缩小 的方法。

可以先点击查看效果链接,建议在Retina屏幕移动端查看:移动端1px,可直接使用手机扫码下方二维码在这里插入图片描述

效果如下:
在这里插入图片描述

这里只简单介绍两种常用的,其他的举一反三就可以。

按钮边框

Retina屏幕移动端查看上面的例子,可以发现按钮直接设置 border: 1px solid #aaa; 比使用伪元素宽。下面展示代码:

border: 1px solid #aaa;

<button class="button">按钮</button>
<style>
    .button {
      padding: 0 12px;
      height: 30px;
      cursor: pointer;
      border: 1px solid #aaa;
      border-radius: 3px;
    }
</style>

伪元素:

<button class="button1">按钮</button>
<style>
    .button1 {
      padding: 0 12px;
      height: 30px;
      cursor: pointer;
      position: relative;
      border: 0;
      border-radius: 3px;
    }
    .button1::after {
      content: " ";
      width: 200%;
      height: 200%;
      position: absolute;
      top: 0;
      left: 0;
      border: 1px solid #aaa;
      transform: scale(.5);
      transform-origin: 0 0;
      box-sizing: border-box;
      border-radius: 6px;
    }
</style>

边框

border: 1px solid #aaa;

<div class="border-bottom-1"></div>
<style>
    .border-bottom-1 {
      border-bottom: 1px solid #aaa;
    }
</style>

伪元素:

<div class="border-bottom-2"></div>
<style>
    .border-bottom-2 {
      position: relative;
    }
    .border-bottom-2::after {
      content: " ";
      width: 200%;
      height: 1px;
      position: absolute;
      top: 0;
      left: 0;
      border-bottom: 1px solid #aaa;
      transform: scale(.5);
      transform-origin: 0 0;
      box-sizing: border-box;
    }
</style>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值