• 单选按钮组选中的按钮默认样式替换成图片


     要实现下面单选按钮组的选中状态用图片显示: 

    html结构:

                  <div class="select-radio-box">
                                <div class="select-box">
                                    <input value="0" type="radio" name="sex" id="male" checked="checked">
                                        <label for="male">男士</label>
                                </div>
                                <div class="select-box">
                                    <input value="1" type="radio" name="sex"  id="female">
                                        <label for="female">女士</label>
                                </div>
                                    <div class="select-box">
                                    <input value="2" type="radio" name="sex"  id="secrecy">
                                        <label for="secrecy">保密</label>
                                </div>
                            </div>

    样式: 

    /*单选按钮 Begin*/
    .select-radio-box {
        display: inline-block;
    }
    .select-box {
        display: inline-block;
        margin-right: 78px;
        box-sizing: border-box;
        padding-left: 42px;
        position: relative;
    }
    .select-box input {
        width: 0;
        height: 0;
        margin-right: 12px;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 0;
    }
     /*input 选中前的样式*/
    .select-box input[type="radio"] + label:before {
        content: "a0";  /*不换行空格*/
        display: inline-block;
        width: 20px;
        height: 20px;
        background-color: #ffffff;
        border-radius: 2px;
        border: solid 1px #dddddd;
        vertical-align: middle;
        margin-right: 12px;
        position: absolute;
        top: 32px;
        left: 0;
        behavior:url("/jrcz/js/pie_file/PIE.htc");
     }
     /*input 选中后的样式 */
     .select-box input[type="radio"]:checked + label:before {
        border: solid 1px #2266cb;
        background:#2266cb url(../images/icons/get_icon.png) no-repeat center center;/*背景图的写法是生效的*/
     }
  • 相关阅读:
    理性与感性
    JVM系列(之class文件)
    Java集合框架
    Java字符串连接的几种方式
    JVM系列(之ClassLoader)
    时之终结
    约束中的存在
    拿什么爱你?我的数学
    梦的表征、抽象的思维
    Spider with R
  • 原文地址:https://www.cnblogs.com/stella1024/p/8808448.html
Copyright © 2020-2023  润新知