zoukankan      html  css  js  c++  java
  • 单选按钮组选中的按钮默认样式替换成图片

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

    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;/*背景图的写法是生效的*/
     }
  • 相关阅读:
    MySQL的小Tips
    Linux中Eclipse下搭建Web开发环境
    SaaS的那些事儿
    典型的软件过程模型
    浅谈「敏捷」开发
    软件工程的本质
    堆和优先队列
    c 判断文件或文件夹是否存在,多种方法, 为什么从一开始就不直接来个统一的呢?
    大江河流尽
    jpg、png格式的图片转换成webp后颜色失真的问题
  • 原文地址:https://www.cnblogs.com/stella1024/p/8808448.html
Copyright © 2011-2022 走看看