checkbox和radio的美化

checkbox:

<style type="text/css">
    input[type="checkbox"]
    {
        display: none;
    }

        input[type="checkbox"] + label
        {
            display: inline-block;
            position: relative;
            border: solid 2px #99a1a7;
            width: 35px;
            height: 35px;
            line-height: 35px;
            border-radius: 4px;
        }

        input[type="checkbox"]:checked + label:after
        {
            content: ‘\2714‘;
            font-size: 25px;
            color: #99a1a7;
            width: 35px;
            height: 35px;
            line-height: 35px;
            position: absolute;
            text-align: center;
            background-color: #e9ecee;
        }

    .tab
    {
        margin-top: 20px;
        margin-bottom: 20px;
        width: 100%;
    }

        .tab td
        {
            border: solid 1px #f99;
            font-size: 25px;
            line-height: 39px;
        }
</style>

<table class="tab" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
    <tr>
        <td>
            <div align="center" style="float: left; height: 39px; width: 39px;">
                <input id="ck101" type="checkbox" />
                <label for="ck101"></label>
            </div>
            <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                测试101
            </div>
            <div align="center" style="float: left; height: 39px; width: 39px;">
                <input id="ck102" type="checkbox" />
                <label for="ck102"></label>
            </div>
            <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                测试102
            </div>
            测试
        </td>
        <td></td>
    </tr>
    <tr>
        <td style="text-align: center;">
            <div style="display: inline-block;">
                <div align="center" style="float: left; height: 39px; width: 39px;">
                    <input id="ck103" type="checkbox" />
                    <label for="ck103"></label>
                </div>
                <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                    测试103
                </div>
                <div align="center" style="float: left; height: 39px; width: 39px;">
                    <input id="ck104" type="checkbox" />
                    <label for="ck104"></label>
                </div>
                <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                    测试104
                </div>
                测试
            </div>
        </td>
        <td>测试
        </td>
    </tr>
</table>

<div style="border: solid 1px #f99; height: 39px; margin-top: 20px; margin-bottom: 20px;">
    <div align="center" style="float: left; height: 39px; width: 39px;">
        <input id="ck201" type="checkbox" />
        <label for="ck201"></label>
    </div>
    <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
        测试201
    </div>
    <div align="center" style="float: left; height: 39px; width: 39px;">
        <input id="ck202" type="checkbox" />
        <label for="ck202"></label>
    </div>
    <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px;">
        测试202
    </div>
</div>

radio:

<style type="text/css">
    input[type="radio"]
    {
        display: none;
    }

        input[type="radio"] + label
        {
            display: inline-block;
            position: relative;
            border: solid 2px #99a1a7;
            width: 25px;
            height: 25px;
            line-height: 25px;
            padding: 5px;
            border-radius: 19.5px;
        }

        input[type="radio"]:checked + label:after
        {
            content: ‘ ‘;
            font-size: 25px;
            color: #99a1a7;
            width: 25px;
            height: 25px;
            line-height: 25px;
            position: absolute;
            text-align: center;
            background-color: #99a1a7;
            border-radius: 12.5px;
        }

        input[type="radio"]:checked + label
        {
            background-color: #e9ecee;
        }

    .tab
    {
        margin-top: 20px;
        margin-bottom: 20px;
        width: 100%;
    }

        .tab td
        {
            border: solid 1px #f99;
            font-size: 25px;
            line-height: 39px;
        }
</style>

<table class="tab" cellpadding="0" cellspacing="0" style="border-collapse: collapse;">
    <tr>
        <td>
            <div align="center" style="float: left; height: 39px; width: 39px;">
                <input id="rd101" name="rd" type="radio" />
                <label for="rd101"></label>
            </div>
            <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                测试101
            </div>
            <div align="center" style="float: left; height: 39px; width: 39px;">
                <input id="rd102" name="rd" type="radio" />
                <label for="rd102"></label>
            </div>
            <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                测试102
            </div>
            测试
        </td>
        <td></td>
    </tr>
    <tr>
        <td style="text-align: center;">
            <div style="display: inline-block;">
                <div align="center" style="float: left; height: 39px; width: 39px;">
                    <input id="rd103" name="rd" type="radio" />
                    <label for="rd103"></label>
                </div>
                <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                    测试103
                </div>
                <div align="center" style="float: left; height: 39px; width: 39px;">
                    <input id="rd104" name="rd" type="radio" />
                    <label for="rd104"></label>
                </div>
                <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
                    测试104
                </div>
                测试
            </div>
        </td>
        <td>测试
        </td>
    </tr>
</table>

<div style="border: solid 1px #f99; height: 39px; margin-top: 20px; margin-bottom: 20px;">
    <div align="center" style="float: left; height: 39px; width: 39px;">
        <input id="rd201" name="rd" type="radio" />
        <label for="rd201"></label>
    </div>
    <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px; margin-right: 20px;">
        测试201
    </div>
    <div align="center" style="float: left; height: 39px; width: 39px;">
        <input id="rd202" name="rd" type="radio" />
        <label for="rd202"></label>
    </div>
    <div style="float: left; height: 39px; line-height: 39px; font-size: 25px; margin-left: 10px;">
        测试202
    </div>
</div>

效果图:

时间: 2024-08-13 16:14:48

checkbox和radio的美化的相关文章

HTML的checkbox和radio的美化

checkbox和radio的美化 checkbox: <style type="text/css"> input[type="checkbox"] { display: none; } input[type="checkbox"] + label { display: inline-block; position: relative; border: solid 2px #99a1a7; width: 35px; height: 3

css input checkbox和radio样式美化

css input checkbox和radio样式美化 2014年9月1日 132495次浏览 在之前的一篇文章中,我已经介绍了input file上传按钮的美化,地址:http://www.haorooms.com/post/css_input_uploadmh ,今天,我们来讲一下checkbox美化和radio美化,关于select下拉框的美化的话,要用一个jquery插件了,这个插件后面我们再讲!急用的同学可以留言! 但是像checkbox美化和radio美化,input美化,根本就不

checkbox和radio样式美化

看惯了input[checkbox]和input[radio]默认样式,有没有想要改变一下呢?比如下面的样式: 比起html默认的样式,上图这些是不是美观多了呢?并且这样的input美化,无需jquery插件,只要几行css代码就可以. 思路 思路很简单:(1)将之前的按钮透明度opacity设置为0:(2)外层用div包裹 实现过程 图片下载:       [html代码] <div class="hdz_input_radio checked"><input ty

论checkbox和radio的样式美化问题

如果你下定决心要改变现有的默认的checkbox和radio的样式,那么我目前有两种办法: 1.自己动手写一个,也就是自己写代码实现将input的checkbox和radio默认的样式隐藏掉,使用绝对定位的方式,手动切换checked和unchecked的图片,定位到原来input显示的地方: 2.使用jQuery的iCheck插件 . 中文DOC地址:http://www.bootcss.com/p/icheck/ github地址:https://github.com/fronteed/iC

checkbox和radio的样式美化问题

如果你下定决心要改变现有的默认的checkbox和radio的样式,那么我目前有两种办法: 1.自己动手写一个,也就是自己写代码实现将input的checkbox和radio默认的样式隐藏掉,使用绝对定位的方式,手动切换checked和unchecked的图片,定位到原来input显示的地方: 2.使用jQuery的iCheck插件 . 中文DOC地址:http://www.bootcss.com/p/icheck/ github地址:https://github.com/fronteed/iC

jQuery实现自定义checkbox和radio样式

jQuery实现自定义checkbox和radio样式 1,起因 最近在工作中要实现自定义式的radio样式,而我们通常使用的时默认的样式,因为自己实在想不到解决的方法,于是开始搜索,最终看到了不错的解决办法,可以完美解决我们遇到的问题. 2,原理 大家都知道在写结构的时候,radio或checkbox都会跟随label一起使用,label的for属性值和input的id值相同的情况下,点击label就可以选中input,这里正是利用label 来覆盖我们的input默认样式,通过给label添

自定义表单样式之checkbox和radio

1,起因 最近在工作中要实现自定义式的radio样式,而我们通常使用的时默认的样式,因为自己实在想不到解决的方法,于是开始搜索,最终看到了不错的解决办法,可以完美解决我们遇到的问题. 2,原理 大家都知道在写结构的时候,radio或checkbox都会跟随label一起使用,label的for属性值和input的id值相同的情况下,点击label就可以选中input,这里正是利用label 来覆盖我们的input默认样式,通过给label添加背景图片(美化的checkbox或radio),也就是

多组checkbox与radio判断选中

有多组checkbox和radio,每组都必须有选择才能提交表单 简单代码如下 html代码:(就是3组checkbox,3组radio,checkbox类名为control-group checkbox:radio类名为control-group radio) <form method="POST" id="wxform" action="xxxx" class="form-horizontal"> <di

巧用CSS3伪类选择器自定义checkbox和radio的样式

由于原生的checkbox和radio的样式太简陋了,在设计页面的时候,设计师往往会设计自己的checkbox和radio样式.一半情况下,为了适应各个浏览器的兼容性,我们都会用其他的元素替代原生的checkbox和radio,然后用js实现选中和未选中时候的样式,用来模拟checkbox和radio. 例如这种: 用其他元素模拟(以checkbox为例): <div class='checkbox'></div> $('.checkbox').click(function(){