zoukankan      html  css  js  c++  java
  • input单选框美化——自定义样式

    方法一:

    给input添加

    -webkit-appearance: none;

    隐藏默认样式。然后添加自己的样式就好了。

    例如:

    复制代码
    .radioBox input{
        -webkit-appearance: none;
         20px;
        height: 20px;
        padding: 0;
        background-color: #fff;
        border: 1px solid #c9c9c9;
        border-radius: 50%;
        outline: none;
        margin-right: 22px;
        cursor: pointer;
    }
    复制代码

     选中时的样式:

    .radioBox input:checked{
        background: url('../img/checkBox_selected.png') no-repeat center;
    }

    效果:

    方法二:

    添加label,给label添加样式,隐藏input

    html:

    复制代码
    <div class="radioBox">
      <input type="radio" value="yes" name="reserve" id="radio_yes">
      <label for="radio_yes">是</label>
      <input type="radio" value="no" name="reserve" id="radio_no">   <label for="radio_no">否</label> </div>
    复制代码

    css

    复制代码
    .radioBox input{
       display: none;
    }
    .radioBox label{
        cursor: pointer;
        position: relative;
    }
    .radioBox label::before{
        display: inline-block;
        content: "";
         16px;
        height: 16px;
        border-radius: 50%;
        border: 2px solid rgba(193, 200, 211, 1);
        margin-right: 6px;
        vertical-align: middle;
    }
    /* 选中 */
    .radioBox input:checked+label::after{
        display: inline-block;
        content: "";
         12px;
        height: 12px;
        border-radius: 50%;
        position: absolute;
        left: 4px;
        bottom: 4px;
        background-color: rgba(56, 85, 127, 1);
    }
    复制代码

    效果:

     
  • 相关阅读:
    [CF786B] Legacy
    [CF833B] The Bakery
    [JSOI2008] 最小生成树计数
    [SDOI2010] 外星千足虫
    [POJ1830] 开关问题
    [Luogu1365] WJMZBMR打osu! / Easy
    [Noip2016] 换教室
    [NOI2002] 荒岛野人
    [计蒜之道复赛 2018] 贝壳找房计数比赛
    [SDOI2014] 旅行
  • 原文地址:https://www.cnblogs.com/Ao-min/p/13396211.html
Copyright © 2011-2022 走看看