zoukankan      html  css  js  c++  java
  • radio按钮样式美化和checkbox按钮样式美化

    思路:在原控件外模拟效果,隐藏原生控件。

    1 radio按钮样式美化

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         .pay_list_c1 {
     8             width: 24px;
     9             height: 18px;
    10             float: left;
    11             padding-top: 3px;
    12             cursor: pointer;
    13             text-align: center;
    14             margin-right: 10px;
    15             background-image: url(images/inputradio.gif);
    16             background-repeat: no-repeat;
    17             background-position: -24px 0;
    18         }
    19         .radioclass {
    20             opacity: 0;
    21             cursor: pointer;
    22             -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    23             filter: alpha(opacity=0);
    24         }
    25         .on {
    26             background-position: 0 0;
    27         }
    28     </style>
    29 </head>
    30 <body>
    31 <span class="pay_list_c1">
    32 <input type="radio" checked="checked" name="paylist" value="1" class="radioclass">
    33 </span>
    34 <span class="pay_list_c1">
    35 <input type="radio" checked="checked" name="paylist" value="1" class="radioclass">
    36 </span>
    37 <script src=jquery.min.js>
    38 
    39 </script>
    40 <script>
    41     $(".pay_list_c1").on("click",function(){
    42         $(this).addClass("on").siblings().removeClass("on");
    43     })
    44 </script>
    45 </body>
    46 </html>

    所用到的图片:   直接复制即可

    2 checkbox按钮样式美化

     1 <!DOCTYPE html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <title>Title</title>
     6     <style>
     7         .piaochecked {
     8             width: 20px;
     9             height: 20px;
    10             float: left;
    11             cursor: pointer;
    12             margin-left: 10px;
    13             text-align: center;
    14             background-image: url(images/checkbox_01.gif);
    15             background-repeat: no-repeat;
    16             background-position: 0 0;
    17         }
    18 
    19         .on_check {
    20             background-position: 0 -21px;
    21         }
    22         .radioclass {
    23             opacity: 0;
    24             cursor: pointer;
    25             -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
    26             filter: alpha(opacity=0);
    27         }
    28     </style>
    29 </head>
    30 <body>
    31 <div class="piaochecked on_check">
    32     <input name="need_inv" type="checkbox" style="height:20px;20px;" class="radioclass" value="1">
    33 </div>
    34 <div class="piaochecked on_check">
    35     <input name="need_inv" type="checkbox" style="height:20px;20px;" class="radioclass" value="1">
    36 </div>
    37 <script src=jquery.min.js></script>
    38 <script>
    39     $(".piaochecked").on("click",function(){
    40         $(this).hasClass("on_check")? $(this).removeClass("on_check"):$(this).addClass("on_check");
    41         //或者这么写
    42         // $(this).toggleClass( "on_check" );
    43     })
    44 </script>
    45 </body>
    46 </html>
  • 相关阅读:
    (一)Python入门-3序列:04列表-元素删除的3种方式-删除本质是数组元素拷贝
    (一)Python入门-3序列:05列表-元素的访问-元素出现次数统计-成员资格判断
    Java学习笔记_180704_final和static关键字
    Java学习笔记_180702_基本类型和引用类型作为参数传递特性
    Java学习笔记_180702_面向对象编程
    如何手动实现整型数值60的二进制到十六进制的转换
    Java学习笔记_180627_循环控制语句
    兔子生兔子问题(斐波那契数列)
    Java学习笔记_180625_基础语法
    ubuntu和win10双系统,用ubuntu引导win10启动
  • 原文地址:https://www.cnblogs.com/wu-hou/p/6378273.html
Copyright © 2011-2022 走看看