网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 单选按钮多选按钮用图片实现加样式
内容
    之前一直看到有人在问,单选按钮和多选按钮怎么加样式、怎么把按钮变大?下面把我做的一个例子分享出来。
    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>
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/17 2:47:09