css 前端 由于尺寸太小导致的 宽高设置无效 或字体大小设置无效 解决方法记录

项目背景:用CSS画了一个单选框 但是在不同手机显示的却不圆

部分代码

.Ma_sign_sex{
          width: 28px;
          height: 28px;
          margin-left: 16px;
          border: 2px solid #bfbfbf;
          border-radius: 50%;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .Ma_sign_sexChoosed{
          position: absolute;
          width: 14px;
          height: 14px;
          background: #ef8542;
          border-radius: 50%;
        }

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

在手机端会出现不圆的情况 是由于适配 px自动转化为rem 但是太小了 导致不规则

解决办法:

.Ma_sign_sex{
          width: 56px;
          height: 56px; //将宽高设置为原来的2倍
          margin-left: 8px; //由于scale缩小 该元素占据的大小仍是缩放前的 所以我把原来的左边距也缩小了1倍
          border: 2px solid #bfbfbf;
          border-radius: 100%;
          position: relative;
          display: flex;
          align-items: center;
          justify-content: center;
          transform: scale(0.5);//这里让整体缩小为原来的1/2
        }
        .Ma_sign_sexChoosed{
          position: absolute;
          width: 28px;
          height: 28px; //将宽高设置为原来的2倍
          background: #ef8542;
          border-radius: 50%;
        }

新手记录 如有更好的方法欢迎交流

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值