<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Examples</title>
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no" name="viewport"/>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<style>
* {
box-sizing: border-box;
}
html,
body {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: #1abc9c;
font-family: 'Roboto', sans-serif;
}
.list {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
margin: 0;
padding: 0;
width: 80%;
max-width: 500px;
background-color: #fff;
border-radius: 6px;
box-shadow: 10px 10px 0 0 rgba(0, 0, 0, 0.2);
list-style: none;
overflow: hidden;
}
.list .list-item {
margin: 0;
padding: 0;
border-bottom: 1px solid #ecf0f1;
position: relative;
}
.list .list-item:last-child {
border: 0;
}
.hidden-box {
position: absolute;
top: -9999px;
left: -9999px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
opacity: 0;
}
.check--label {
font-size: 20px;
margin: 0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}
.check--label-box {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
position: relative;
height: 20px;
width: 20px;
margin: 0 20px;
border: 2px solid #3498db;
border-radius: 2px;
cursor: pointer;
}
.check--label-text {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-self: center;
-ms-flex-item-align: center;
align-self: center;
position: relative;
cursor: pointer;
padding: 20px;
border-left: 1px solid #ecf0f1;
}
.check--label-text:after {
content: '';
display: block;
width: 0%;
height: 2px;
background-color: #000;
position: absolute;
top: 50%;
left: 7.5%;
/* -webkit-transform: translateY(-50%);
transform: translateY(-50%);*/
-webkit-transition: width 100ms ease-in-out;
transition: width 100ms ease-in-out;
}
.hidden-box:checked + .check--label {
background-color:red;
}
.hidden-box:checked + .check--label .check--label-box {
color: yellow
}
.hidden-box:checked + .check--label .check--label-box:after {
content: '';
display: block;
position: absolute;
top: -1px;
left: 4px;
width: 6px;
height: 12px;
border: solid #000;
border-width: 0 2px 2px 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.hidden-box:checked + .check--label .check--label-text:after {
width: 85%;
}
</style>
<body>
<ul class="list">
<li class="list-item">
<input type="checkbox" class="hidden-box" id="first" checked/>
<label for="first" class="check--label">
<span class="check--label-box"></span>
<span class="check--label-text">First Checkbox</span>
</label>
</li>
<li class="list-item">
<input type="checkbox" class="hidden-box" id="second" />
<label for="second" class="check--label">
<span class="check--label-box"></span>
<span class="check--label-text">Second Checkbox</span>
</label>
</li>
<li class="list-item">
<input type="checkbox" class="hidden-box" id="third" />
<label for="third" class="check--label">
<span class="check--label-box"></span>
<span class="check--label-text">Third Checkbox</span>
</label>
</li>
</ul>
</body>
</html>
03-12
1873
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-15
1050
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)