改变input (radio,check)的样式

第一种

  1. 效果
    在这里插入图片描述
  2. html
<input type="radio"><style>
        input[type=checkbox] {
            cursor: pointer;
            position: relative;
            width: 15px;
            height: 15px;
            font-size: 14px;
        }

        input[type=checkbox]::after {
            position: absolute;
            top: 0;
            color: #000;
            width: 15px;
            height: 15px;
            display: inline-block;
            text-align: center;
            content: ' ';
        }

        input[type=checkbox]:checked::after {
            content: "✓";
            color: #fff;
            font-size: 12px;
            font-weight: bold;
            background-color: #ff366f;

			border-radius: 50%; //radio
        }
    </style>

第二种

  1. 效果
    在这里插入图片描述
    2.html
<style>
	.hide {
      display: none;
    }

    .square {
      background-color: #fff;
      border: 1px solid #bfbfbf;
      display: inline-block;
      height: 0.9em;
      padding: 2px;
      border-radius: 100%;
      margin-right: 5px;
      margin-top: -2px;
      vertical-align: middle;
      width: 0.9em;
      line-height: 1;
      box-sizing: content-box;
    }

    .hide:checked+.square:after {
      background-color: #ffd958;
      content: "";
      display: inline-block;
      height: 0.9em;
      width: 0.9em;
      vertical-align: top;
      border-radius: 100%;
    }

    .hide:checked+.square {
      border: 1px solid #ffd958;
    }
</style>
<input class="hide" type="radio" name="sex" id="tbb">
<span class="square"></span>
<span>b</span>

第三种

  1. 效果
    在这里插入图片描述
    2.html
<input type="radio"><style>
        input[type=checkbox] {
            cursor: pointer;
            position: relative;
            width: 15px;
            height: 15px;
            font-size: 14px;
        }

        input[type=checkbox]::after {
            position: absolute;
            top: -1px;
   			left: 1px;
            color: #000;
            content: ' ';
        }

        input[type=checkbox]:checked::after {
            content: "✓";
      		color: #ff366f;
	        font-size: 12px;
	        font-weight: bold;
        }
    </style>

第四种:添加背景图

  1. 效果
    在这里插入图片描述
<input type="checkbox">
<style>
 	input[type=checkbox] {
      background-color: #fff;
      -webkit-appearance: none;
      border: 1px solid #000;
      width: 14px;
      height: 14px;
      border: none;
    }

    input[type=checkbox]:checked {
      background-image: url(../../static/admin/images/icon_2.png);
      background-size: contain;
    }
</style>
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值