• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    单选按钮、多选按钮用图片实现加样式
    之前一直看到有人在问,单选按钮和多选按钮怎么加样式、怎么把按钮变大?下面把我做的一个例子分享出来。

    1.首先把按钮做成图片
     

    2.html页面

    复制代码
    代码如下:

    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    $(function(){
    $("input[type='checkbox']").click(function(){
    if($(this).is(':checked')){
    $(this).attr("checked","checked");
    $(this).parent().removeClass("c_off").addClass("c_on");
    }else{
    $(this).removeAttr("checked");
    $(this).parent().removeClass("c_on").addClass(" c_off");
    }
    });
    $("input[type='radio']").click(function(){
    $("input[type='radio']").removeAttr("checked");
    $(this).attr("checked","checked");
    $(this).parent().removeClass("r_off").addClass("r_on").siblings().removeClass("r_on").addClass("r_off");
    });
    });
    </script>
    </head>
    <style>
    /* 多选/单选 */
    label {
    display: block;
    cursor: pointer;
    line-height: 26px;
    margin-bottom: 20px;
    width: 26px;
    height: 26px;
    line-height: 26px;
    float: left;
    margin-top: 6px;
    }
    .radios {
    padding-top: 18px;
    border-top: 1px solid #049CDB;
    }
    .label_check input, .label_radio input {
    margin-right: 5px;
    }
    .lblby .label_check, .lblby .label_radio {
    margin-right: 8px;
    }
    .lblby .label_radio, .lblby .label_check {
    background: url(../images/jxc_btn.png) no-repeat;
    }
    .lblby .label_check {
    background-position: 0 0px
    }
    .lblby label.c_on {
    background-position: 0 -26px;
    }
    .lblby .label_radio {
    background-position: 0 -52px;
    }
    .lblby label.r_on {
    background-position: 0 -78px;
    }
    .lblby .label_check input, .lblby .label_radio input {
    position: absolute;
    left: -9999px;
    }
    </style>
    <body class="lblby">
    <label for="checkbox-01" class="label_check c_on">
    <input type="checkbox" checked="checked" value="1" id="checkbox-01" name="sample-checkbox-01" />
    Checkbox1 </label>
    <label for="checkbox-02" class="label_check">
    <input type="checkbox" value="1" id="checkbox-02" name="sample-checkbox-02" />
    Checkbox2</label>
    <label for="radio-01" class="label_radio r_on">
    <input type="radio" value="1" checked="checked" id="radio-01" name="sample-radio" />
    Radio1 </label>
    <label for="radio-02" class="label_radio r_off">
    <input type="radio" value="1" id="radio-02" name="sample-radio" />
    Radio2 </label>
    <label for="radio-03" class="label_radio r_off">
    <input type="radio" value="1" id="radio-03" name="sample-radio" />
    Radio3 </label>
    </body>
    </html>
    上一篇:html借助marquee实现文字左右滚动
    下一篇:HTML中禁用表单控件的两种方法readonly与disabled
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    单选按钮、多选按钮用图片实现加样式 单选,按钮,多选,用,图片,