HTML的checkbox和radio样式美化的简单实例

所属分类: 网页制作 / HTML/Xhtml 阅读数: 1803
收藏 0 赞 0 分享

HTML的checkbox和radio样式美化的简单实例

checkbox:

XML/HTML Code复制内容到剪贴板
  1. <style type="text/css">  
  2.     input[type="checkbox"]   
  3.     {   
  4.         display: none;   
  5.     }   
  6.   
  7.         input[type="checkbox"] + label   
  8.         {   
  9.             display: inline-block;   
  10.             position: relative;   
  11.             border: solid 2px #99a1a7;   
  12.             width: 35px;   
  13.             height: 35px;   
  14.             line-height: 35px;   
  15.             border-radius: 4px;   
  16.         }   
  17.   
  18.         input[type="checkbox"]:checked + label:after   
  19.         {   
  20.             content: '\2714';   
  21.             font-size: 25px;   
  22.             color: #99a1a7;   
  23.             width: 35px;   
  24.             height: 35px;   
  25.             line-height: 35px;   
  26.             position: absolute;   
  27.             text-align: center;   
  28.             background-color: #e9ecee;   
  29.         }   
  30.   
  31.     .tab   
  32.     {   
  33.         margin-top: 20px;   
  34.         margin-bottom: 20px;   
  35.         width: 100%;   
  36.     }   
  37.   
  38.         .tab td   
  39.         {   
  40.             border: solid 1px #f99;   
  41.             font-size: 25px;   
  42.             line-height: 39px;   
  43.         }   
  44. </style>  
  45.   
  46. <table class="tab" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">  
  47.     <tr>  
  48.         <td>  
  49.             <div align="center" style="float: left; height: 39px; width: 39px;">  
  50.                 <input id="ck101" type="checkbox" />  
  51.                 <label for="ck101"></label>  
  52.             </div>  
  53.             <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  54.                 测试101   
  55.             </div>  
  56.             <div align="center" style="float: left; height: 39px; width: 39px;">  
  57.                 <input id="ck102" type="checkbox" />  
  58.                 <label for="ck102"></label>  
  59.             </div>  
  60.             <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  61.                 测试102   
  62.             </div>  
  63.             测试   
  64.         </td>  
  65.         <td></td>  
  66.     </tr>  
  67.     <tr>  
  68.         <td style="text-align: center;">  
  69.             <div style="display: inline-block;">  
  70.                 <div align="center" style="float: left; height: 39px; width: 39px;">  
  71.                     <input id="ck103" type="checkbox" />  
  72.                     <label for="ck103"></label>  
  73.                 </div>  
  74.                 <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  75.                     测试103   
  76.                 </div>  
  77.                 <div align="center" style="float: left; height: 39px; width: 39px;">  
  78.                     <input id="ck104" type="checkbox" />  
  79.                     <label for="ck104"></label>  
  80.                 </div>  
  81.                 <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  82.                     测试104   
  83.                 </div>  
  84.                 测试   
  85.             </div>  
  86.         </td>  
  87.         <td>测试   
  88.         </td>  
  89.     </tr>  
  90. </table>  
  91.   
  92. <div style="border: solid 1px #f99; height: 39px; margin-top: 20px; margin-bottom: 20px;">  
  93.     <div align="center" style="float: left; height: 39px; width: 39px;">  
  94.         <input id="ck201" type="checkbox" />  
  95.         <label for="ck201"></label>  
  96.     </div>  
  97.     <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  98.         测试201   
  99.     </div>  
  100.     <div align="center" style="float: left; height: 39px; width: 39px;">  
  101.         <input id="ck202" type="checkbox" />  
  102.         <label for="ck202"></label>  
  103.     </div>  
  104.     <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px;">  
  105.         测试202   
  106.     </div>  
  107. </div>  

radio:

XML/HTML Code复制内容到剪贴板
  1. <style type="text/css">  
  2.     input[type="radio"]   
  3.     {   
  4.         display: none;   
  5.     }   
  6.   
  7.         input[type="radio"] + label   
  8.         {   
  9.             display: inline-block;   
  10.             position: relative;   
  11.             border: solid 2px #99a1a7;   
  12.             width: 25px;   
  13.             height: 25px;   
  14.             line-height: 25px;   
  15.             padding: 5px;   
  16.             border-radius: 19.5px;   
  17.         }   
  18.   
  19.         input[type="radio"]:checked + label:after   
  20.         {   
  21.             content: ' ';   
  22.             font-size: 25px;   
  23.             color: #99a1a7;   
  24.             width: 25px;   
  25.             height: 25px;   
  26.             line-height: 25px;   
  27.             position: absolute;   
  28.             text-align: center;   
  29.             background-color: #99a1a7;   
  30.             border-radius: 12.5px;   
  31.         }   
  32.   
  33.         input[type="radio"]:checked + label   
  34.         {   
  35.             background-color: #e9ecee;   
  36.         }   
  37.   
  38.     .tab   
  39.     {   
  40.         margin-top: 20px;   
  41.         margin-bottom: 20px;   
  42.         width: 100%;   
  43.     }   
  44.   
  45.         .tab td   
  46.         {   
  47.             border: solid 1px #f99;   
  48.             font-size: 25px;   
  49.             line-height: 39px;   
  50.         }   
  51. </style>  
  52.   
  53. <table class="tab" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">  
  54.     <tr>  
  55.         <td>  
  56.             <div align="center" style="float: left; height: 39px; width: 39px;">  
  57.                 <input id="rd101" name="rd" type="radio" />  
  58.                 <label for="rd101"></label>  
  59.             </div>  
  60.             <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  61.                 测试101   
  62.             </div>  
  63.             <div align="center" style="float: left; height: 39px; width: 39px;">  
  64.                 <input id="rd102" name="rd" type="radio" />  
  65.                 <label for="rd102"></label>  
  66.             </div>  
  67.             <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  68.                 测试102   
  69.             </div>  
  70.             测试   
  71.         </td>  
  72.         <td></td>  
  73.     </tr>  
  74.     <tr>  
  75.         <td style="text-align: center;">  
  76.             <div style="display: inline-block;">  
  77.                 <div align="center" style="float: left; height: 39px; width: 39px;">  
  78.                     <input id="rd103" name="rd" type="radio" />  
  79.                     <label for="rd103"></label>  
  80.                 </div>  
  81.                 <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  82.                     测试103   
  83.                 </div>  
  84.                 <div align="center" style="float: left; height: 39px; width: 39px;">  
  85.                     <input id="rd104" name="rd" type="radio" />  
  86.                     <label for="rd104"></label>  
  87.                 </div>  
  88.                 <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  89.                     测试104   
  90.                 </div>  
  91.                 测试   
  92.             </div>  
  93.         </td>  
  94.         <td>测试   
  95.         </td>  
  96.     </tr>  
  97. </table>  
  98.   
  99. <div style="border: solid 1px #f99; height: 39px; margin-top: 20px; margin-bottom: 20px;">  
  100.     <div align="center" style="float: left; height: 39px; width: 39px;">  
  101.         <input id="rd201" name="rd" type="radio" />  
  102.         <label for="rd201"></label>  
  103.     </div>  
  104.     <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">  
  105.         测试201   
  106.     </div>  
  107.     <div align="center" style="float: left; height: 39px; width: 39px;">  
  108.         <input id="rd202" name="rd" type="radio" />  
  109.         <label for="rd202"></label>  
  110.     </div>  
  111.     <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px;">  
  112.         测试202   
  113.     </div>  
  114. </div>  

 效果图:

以上这篇HTML的checkbox和radio样式美化的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

原文地址:http://www.cnblogs.com/shouce/archive/2016/06/08/5569173.html

更多精彩内容其他人还在看

XHTML入门学习教程:XHTML超级链接

超级链接<a>标签 毫不夸张的说,是超级链接把整个互联网连接了起来。超级链接几乎可以指向互联网上的任何资源,例如另外一个网页、一张图片、一首MP3歌曲等等。而利用XHTML建立超级链接的语法却非常简单,只需要一对<a></a>标签即可:
收藏 0 赞 0 分享

网页制作解惑:图象文件的路径

本文属于网页教学网闪电儿原创,转载可以去掉这句话,但是不要以任何借口或方式更改文章的内容,否则后果自负!转载请注明作者和出处。 很久以前一直到现在,有好多网友问过我类似的问题,尤其是拷贝了本站的一些图形图像特效代码后,总是图片显示不出来等问题出现,在这
收藏 0 赞 0 分享

HTML教程,简单学习HTML语言

1、<body background=图片文件名 bgcolor=颜色 text=颜色 link=颜色 vlink=颜色 alink=颜色>...</body>标记属性: background:设置网页的背景图像。bgcolor:设置网页的背景颜色。
收藏 0 赞 0 分享

HTML基础:HTML的基本结构

HTML的基本结构   超文本文档分文档头和文档体两部分,在文档头里,对这个文档进行了一些必要的定义,文档体中才是要显示的各种文档信息。 <HTML>    <HEAD>       头 部 信 息    </HEAD>
收藏 0 赞 0 分享

HTML教程,认识optgroup元素

select的分类选择,经测试IE和FF都能很好的支持该元素 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 S
收藏 0 赞 0 分享

网页输入框的样式触发效果

  这个例子主要学习两个参数onblur和onFocus.因为这两个参数以前很少遇到,baidu 一下明白了,onblur 是控件在失去焦点的时候触发的事件,而onFocus就是成为输入焦点的时候触发的事件,这两个参数都可以和className结合直接调用样式表类名
收藏 0 赞 0 分享

HTML教程,HTML默认样式

html, address, blockquote, body, dd, div, dl, dt, fieldset, form, frame, frameset, h1, h2, h3, h4,
收藏 0 赞 0 分享

超链接打开目标(target)的测试

链接的target属性决定了链接在哪边打开,它的值通常为以下五种:_blank、_self、_parent、_top和自定义,依次表示为:新窗口、当前窗口、父窗口、顶层窗口和框架。当所指名称的框架不存在时,自定义作用等同于_blank。今天我们主要测试一下当所指名称的框架处于不同
收藏 0 赞 0 分享

HTML优化加快网页速度

明显HTML,暗渡“公用脚本” 减少web页面下载时间的关键就是设法减小文件大小。当多个页面共用一些成分内容时,就可以考虑将这些公用部分单独分离出来。比如:我们可以将多个HTML页面都用到的脚本程序编写成独立存在的.js文件,然后再在页面中按如下
收藏 0 赞 0 分享

XHTML教程,简单认识XHTML基础知识

  本文简单让大家认识一下XHTML,了解XHTML的基础知识 什么是XHTML   XHTML是The Extensible HyperText Markup Language(可扩展标识语言)的缩写。HTML是一种基本的WEB网页设计语言,XHTML是一个基于XM
收藏 0 赞 0 分享
查看更多