纯CSS修改checkbox复选框样式
借鉴网友博客, 改用后整理收录
效果图:

移入:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.box_inner1{
width: 25px;
margin: 20px 100px; /*最外层盒子的外边距, 可自己调*/
position: relative;
} .box_inner1 label{
cursor: pointer;
position: absolute;
width: 25px; /*此处width和height是选框显示出来的大小*/
height: 25px;
top:0; /*此处top和left是选框显示出来位置, 可根据需求进行调节*/
left: 0;
background: #e75213; /*此处是复选框背景颜色, 下面是边框颜色, 设置一致是保持统一*/
border: 1px solid #E75213;
} .box_inner1 label:after{
opacity: 1; /*选中后样式的透明度, 1是不透明*/
content: ''; /*选中后的内容 ,此处为空是指把默认的去掉, 下面自定义*/
position: absolute;
width: 9px;
height: 5px;
background: transparent; /*这一块是核心,可以自己调试看效果*/
top: 6px;
left: 7px;
border: 3px solid white;
border-top: none;
border-right: none; /*选中的样式是用盒子div加背景色, 加旋转实现的, 下面的代码是旋转45度*/
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
/*-o-transform: rotate(-45deg);*/
-ms-transform: rotate(-45deg);
transform: rotate(-45deg); } .box_inner1 label:hover::after{
opacity: 0.5; /*鼠标移入移出的透明度*/
} .box_inner1 input[type=checkbox]:checked + label:after{
opacity: 0; /*取消选中*/
} /*要有多个选框, 直接复制一份重命名, 避免冲突*/
/*第二个*/
.box_inner2{
width: 25px;
margin: 20px 100px;
position: relative;
} .box_inner2 label{
cursor: pointer;
position: absolute;
width: 25px;
height: 25px;
top:0;
left: 0;
background: #e75213;
border: 1px solid #E75213;
} .box_inner2 label:after{
opacity: 1;
content: '';
position: absolute;
width: 9px;
height: 5px;
background: transparent;
top: 6px;
left: 7px;
border: 3px solid white;
border-top: none;
border-right: none; -webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
/*-o-transform: rotate(-45deg);*/
-ms-transform: rotate(-45deg);
transform: rotate(-45deg); } .box_inner2 label:hover::after{
opacity: 0.5;
} .box_inner2 input[type=checkbox]:checked + label:after{
opacity: 0;
} input[type=checkbox]{
visibility: hidden;
} </style>
</head>
<body>
<div class="box_inner1">
<input type="checkbox" id="box_innerInput1" />
<label for="box_innerInput1"></label>
</div> <div class="box_inner2">
<input type="checkbox" id="box_innerInput2" />
<label for="box_innerInput2"></label>
</div>
</body>
</html>
参考:
http://www.360doc.com/content/15/0528/11/1355383_473823407.shtml
https://blog.csdn.net/qq_34182808/article/details/79992465
纯CSS修改checkbox复选框样式的更多相关文章
- 纯CSS修改checkbox复选框样式-02
我有用过这个纯修改input属性的 本人修改后的代码和效果图(修的不好), 这个是改动最简单的: css代码 input[type=checkbox]{ visibility: hidden; } i ...
- 转 纯CSS设置Checkbox复选框控件的样式
Checkbox复选框是一个可能每一个网站都在使用的HTML元素,但大多数人并不给它们设置样式,所以在绝大多数网站它们看起来是一样的.为什么不把你的网站中的Checkbox设置一个与众不同的样式,甚至 ...
- 【转】纯CSS设置Checkbox复选框控件的样式
Checkbox复选框是一个可能每一个网站都在使用的HTML元素,但大多数人并不给它们设置样式,所以在绝大多数网站它们看起来是一样的.为什么不把你的网站中的Checkbox设置一个与众不同的样式,甚至 ...
- 纯CSS设置Checkbox复选框控件的样式
Checkbox复选框是一个可能每一个网站都在使用的HTML元素,但大多数人并不给它们设置样式,所以在绝大多数网站它们看起来是一样的.为什么不把你的网站中的Checkbox设置一个与众不同的样式,甚至 ...
- ZH奶酪:纯CSS自定义Html中Checkbox复选框样式
原文链接:http://www.lrxin.com/archives-683.html 首先看下效果: 点击演示地址查看实例. 首先,需要添加一段CSS隐藏所有的Checkbox复选框,之后我们会改变 ...
- checkbox复选框样式
随着现代浏览器的流行,纯CSS设置checkbox也变的很是实用,下面会讲到5种与众不同的checkbox复选框. 首先,需要添加一段CSS隐藏所有的Checkbox复选框,下面我们会改变它的外观.要 ...
- css input checkbox复选框控件 样式美化的多种方案
checkbox复选框可能是网站中常用的html元素,但大多数人并不满意它的默认样式,这篇文章就讲讲如何实现input checkbox复选框控件 样式美化效果. 资源网站大全 https://55w ...
- 原创:纯CSS美化单复选框(checkbox、radio)
最重要的一点,隐藏选择框本身.不多说了,上代码: <!doctype html> <html> <head> <meta charset="utf- ...
- css 设置 checkbox复选框控件的对勾√样式
效果 最终的样式,想要的效果: 我们要创建方框中的对勾,对于这一点,我们可以使用:after伪类创建一个新的元素,为了实现这个样式,我们可以创建一个5px * 15px的长方形并给他加上边框. ...
随机推荐
- Java作业十三(2017-11-20)
/*使用一位数组解决 1 1 2 3 5 8 13 数列问题 斐波纳契数列 Fibonacci*/ package cn.GM; public class array { public static ...
- Azure Web连接到Azure MySql Db
这个问题折腾了好一会,简单记录一下. 两种方式: 输入"规则名称"."起始 IP"和"结束 IP",然后单击"保存". ...
- 请求ajax失败的原因(进入到error)
原因: dataType 定义类型和返回类型不一致,我定义的json格式数据. {data:[],num:0} 这种是不规则的字符串,不是严格的json格式 应该改成{"data" ...
- [Swift]LeetCode797. 所有可能的路径 | All Paths From Source to Target
Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N-1, and re ...
- [Swift]LeetCode881. 救生艇 | Boats to Save People
The i-th person has weight people[i], and each boat can carry a maximum weight of limit. Each boat c ...
- [Swift]LeetCode971.翻转二叉树以匹配先序遍历 | Flip Binary Tree To Match Preorder Traversal
Given a binary tree with N nodes, each node has a different value from {1, ..., N}. A node in this b ...
- linux中的shell脚本编程---初识shell
Shell是用户与Linux或Unix内核通信的工具,shell编程指的并不是编写这个工具,而是指利用现有的shell工具进行编程,写出来的程序是轻量级的脚本,我们叫做shell脚本. Shell的语 ...
- python日志syslog运用
syslog的官方说明在: https://docs.python.org/2/library/syslog.html#module-syslog 该模块的主要方式为: #!/usr/bin/pyth ...
- Python内置函数(4)——ascii
英文文档: ascii(object) As repr(), return a string containing a printable representation of an object, b ...
- 面向切面编程 ( Aspect Oriented Programming with Spring )
Aspect Oriented Programming with Spring 1. 简介 AOP是与OOP不同的一种程序结构.在OOP编程中,模块的单位是class(类):然而,在AOP编程中模块的 ...