更新第73个小实例
This commit is contained in:
parent
f379587177
commit
7d10439be5
|
@ -76,4 +76,5 @@
|
|||
69. HTML5+CSS3小实例之动感的环形加载动画
|
||||
70. HTML5+CSS3小实例之图像悬停效果
|
||||
71. HTML5+CSS3小实例之跳跃的弹性小球加载动画
|
||||
72. HTML5+CSS3小实例之白桃粉可爱风的立体字时钟
|
||||
72. HTML5+CSS3小实例之白桃粉可爱风的立体字时钟
|
||||
73. HTML5+CSS3小实例之非常酷炫的拟物化滑动开关
|
|
@ -0,0 +1,94 @@
|
|||
*{
|
||||
/* 初始化 */
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
body{
|
||||
/* 100%窗口高度 */
|
||||
height: 100vh;
|
||||
/* 弹性布局 水平+垂直居中 */
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: #2b2b2b;
|
||||
}
|
||||
.container{
|
||||
/* 弹性布局 纵向排列 */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.container label{
|
||||
/* 相对定位 */
|
||||
position: relative;
|
||||
margin: 5px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.container label span{
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 80px;
|
||||
height: 40px;
|
||||
background-color: #222;
|
||||
border-radius: 40px;
|
||||
/* 内阴影 */
|
||||
box-shadow: inset 0 2px 15px rgba(0,0,0,0.2),
|
||||
inset 0 2px 2px rgba(0,0,0,0.2),
|
||||
inset 0 -1px 1px rgba(0,0,0,0.2);
|
||||
}
|
||||
/* 滑块 */
|
||||
.container label .indicator{
|
||||
/* 绝对定位 */
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
/* 渐变背景 */
|
||||
background: linear-gradient(to bottom,#444,#222);
|
||||
border-radius: 50%;
|
||||
/* 阴影 */
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.5),
|
||||
inset 0 1px 1px rgba(255,255,255,0.1);
|
||||
/* 缩小 */
|
||||
transform: scale(0.9);
|
||||
/* 动画过渡 */
|
||||
transition: 0.5s;
|
||||
}
|
||||
/* 滑块中心的发光点 */
|
||||
.container label .indicator::before{
|
||||
content: "";
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
/* 绝对定位 居中 */
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%,-50%);
|
||||
background-color: #f00;
|
||||
border-radius: 50%;
|
||||
/* 阴影制造发光效果 */
|
||||
box-shadow: 0 0 2px #f00,
|
||||
0 0 5px #f00,
|
||||
0 0 10px #f00,
|
||||
0 0 15px #f00,
|
||||
0 0 20px #f00,
|
||||
0 0 25px #f00,
|
||||
0 0 30px #f00,
|
||||
0 0 35px #f00;
|
||||
transition: 0.5s;
|
||||
}
|
||||
/* 勾选复选框后滑块的变化 */
|
||||
.container label input:checked ~ .indicator{
|
||||
left: 40px;
|
||||
}
|
||||
.container label input:checked ~ .indicator::before{
|
||||
background-color: #0f0;
|
||||
box-shadow: 0 0 2px #0f0,
|
||||
0 0 5px #0f0,
|
||||
0 0 10px #0f0,
|
||||
0 0 15px #0f0,
|
||||
0 0 20px #0f0,
|
||||
0 0 25px #0f0,
|
||||
0 0 30px #0f0,
|
||||
0 0 35px #0f0;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
|
||||
|
||||
<title>非常酷炫的拟物化滑动开关</title>
|
||||
<link rel="stylesheet" href="../css/73.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<label>
|
||||
<input type="checkbox" hidden>
|
||||
<span></span>
|
||||
<i class="indicator"></i>
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" hidden checked>
|
||||
<span></span>
|
||||
<i class="indicator"></i>
|
||||
</label>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue