定制 input[type="radio"] 和 input[type="checkbox"] 样式
表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或者手机上,显示的效果总是不统一,而且难以修改器样式。
input[type="radio"] 样式定制
代码:
<form>
<p>
<input type="radio" name="gender" id="male" value="male">
<label for="male">男士</label>
</p>
<p>
<input type="radio" name="gender" id="female" value="female">
<label for="female">女士</label>
</p>
</form>
css 样式
input[type="radio"] {
height: 22px;
width: 22px;
margin-right: 10px;
display: none;
}
input[type="radio"] + label::before {
content: "\a0"; /*不换行空格*/
display: inline-block;
vertical-align: middle;
font-size: 18px;
width: 18px;
height: 18px;
margin-right: 10px;
border-radius: 50%;
border: 1px solid #003c66;
background: #fff;
line-height: 22px;
box-sizing: border-box;
}
input[type="radio"]:checked + label::before {
background-color: #003c66;
background-clip: content-box;
padding: 3px;
}
效果如图:

input[type="checkbox"] 样式定制
代码:
<form>
<input id="select_all" name="select_all" type="checkbox">
<label for="select_all"> <i></i>选择</label>
</form>
css 样式
input[type="checkbox"] {
display: none;
}
input[type="checkbox"]+label>i {
display: inline-block;
width: 20px;
height: 20px;
border: 1px solid #bbb;
background: #bbb;
margin-right: 10px;
vertical-align: middle;
}
input[type="checkbox"]:checked+label>i {
position: relative;
}
input[type="checkbox"]:checked+label>i::before {
content: '';
position: absolute;
width: 12px;
height: 18px;
color: black;
border-bottom: 1px solid green;
border-right: 1px solid green;
left: 50%;
top: 20%;
transform-origin: center;
transform: translate(-50%, -30%) rotate(40deg);
-webkit-transform: translate(-50%, -30%) rotate(40deg);
}
效果如图:

定制 input[type="radio"] 和 input[type="checkbox"] 样式的更多相关文章
- 修改 input[type="radio"] 和 input[type="checkbox"] 的默认样式
表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...
- <input type="radio" >与<input type="checkbox">值得获取
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...
- 关于jq操作table下多个type=radio的input的选中
假如有2个table: <table id="table1" border="0"> <tr> <td><input ...
- 点击DIV触发其他元素的点击事件(案例:点击type="radio" 的input 标签外层DIV,触发内部单选点击选中事件)
方法一: 直接用找到对应dom元素调用.click()方法 $('.user_content').click(function(){ $(this).children()[0].click(); // ...
- 纯css兼容个浏览器input[type='radio']不能自定义样式
各个浏览器对于表单input[type='radio'].input[type='checkbox']的样式总是各有差异 //html <div class="remember-a ...
- css 能改变input type radio和checkbox 圆圈或方框的大小
把input隐藏,外面套label,再里面加个span,样式写在span上,让label覆盖在span上面,js去改active的class <label for="remember& ...
- input(type="checkbox"|type="radio")+jquery使用
1.用.is(":checked")判断input是否为选中状态 例: var value=$(this).is(":checked"); localStora ...
- 原生javascript自定义input[type=radio]效果
2018年6月27日 更新 找到最为简单的仅仅使用css3的方案 <!DOCTYPE html> <html lang="en"> <head> ...
- 自定义input[type="radio"]的样式
对于表单,input[type="radio"] 的样式总是不那么友好,在不同的浏览器中表现不一. 为了最大程度的显示出它们的差别,并且为了好看,首先定义了一些样式: <fo ...
随机推荐
- 团队项目个人进展——Day10
一.昨天工作总结 冲刺第十天,与小组成员任务合并,并解决结合后的一些问题. 二.遇到的问题 界面还是不太和谐 三.今日工作规划 对页面的布局.wxss做了一些修改
- ChatOps如何变革企业业务
[编者按]本文作者为日志分析软件公司 Logz.io 的联合创始人 Tomer Levy,主要介绍 ChatOps 的特点与发展历程,以及将来可能带来的业务变革.文章系国内 ITOM 管理平台 One ...
- Android的.so文件、ABI和CPU的关系
Android的.so文件.ABI和CPU的关系有篇文章描述的很详细了 见 http://blog.csdn.net/xx326664162/article/details/51163905
- replace 用法
orcl中replace()用法: replace:(字符串 | 列):进行替换: 将bqh1表中name列带“小”的字改成“大”: select * from bqh1select a.*,repl ...
- Apache的权限设置与构建虚拟web主机
实验拓扑图: 实验要求: 1. 搭建WEB服务器,能访问默认站点,并使用awstats软件能监控到默认站点的访问情况. 2. 修改Apache的主配置文件,设置1.10只能访问awstats网站, ...
- 每年有20万人进军IT行业,为何还会人才短缺?
众所周知,IT行业是个高薪行业,也是很多人的梦想职业,在全球最缺人的十大行业中IT行业居首位. 但是现在很多人都有一个疑问: 几乎每所大学里都有计算机技术相关专业,再加上IT培训机构的输出,每年培养出 ...
- 函数式编程的终极形式:面向映射流的编程pipeline
1.单体(数据)映射:基本操作:数据的单次映射: 2.管道流:数据的流程化处理 基础是monand类型,形式是声明式编程: Pipeline模型: 它以一种“链式模型”来串接不同的程序或者不同的组件, ...
- 随手练——HDU 1078 FatMouse and Cheese(记忆化搜索)
http://acm.hdu.edu.cn/showproblem.php?pid=1078 题意: 一张n*n的格子表格,每个格子里有个数,每次能够水平或竖直走k个格子,允许上下左右走,每次走的格子 ...
- MyBatis实战之动态SQL
如果使用JDBC或者其他框架,很多时候你得根据需要去拼接SQL,这是一个麻烦的事情,而MyBatis提供对SQL语句动态的组装能力,而且它只有几个基本的元素,非常简单明了,大量的判断都可以在MyBat ...
- oracle偏爱hostname
记住: 只要是在使用oracle他家的产品,比如oracle database , weblogic :或者诸如此类,等等,等等,随便别的什么东西 首先要查改: /etc/hosts 127.0.0. ...