css实现三维实体按钮灯光开关拨动效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现三维实体按钮灯光开关拨动效果代码

代码标签: 实体 按钮 灯光 开关 拨动 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
<style>
/*** debug in progress ***/
body {
	margin: 0;
	padding: 0;
	width: 100vw;
	height: 100vh;
	perspective: 100vmin;
	overflow: hidden;
}

body * { 
	box-sizing: border-box; 
	outline: none; 
	transition: all 0.5s ease 0s;
}

.container {
	position: fixed;
	width: 100vw;
	height: 100vh;
	display: flex;
	justify-content: center;
	align-items: center;
	top: 0;
	left: 0;
	overflow: hidden;
}

.box {
	width: 36vmin;
	height: 44vmin;
	transform-style: preserve-3d;
	position: absolute;
	box-shadow: 0.15vmin 0 0.5vmin -0.25vmin #c5c5c5;
	z-index: 0;
	border-radius: 3vmin;
	transform: rotateY(30deg);
	background: #3c3c3c;
}

.box:after {
	content: "";
	background: #212121;
	width: 98%;
	height: 98%;
	position: absolute;
	left: 1%;
	transform: translateZ(-1px);
	top: 1%;
	border-radius: 3vmin;
	transition: all 0.5s ease 0s;
}

input#switch:checked + .box  {
	background: transparent;
}

input#switch:checked + .box > label  {
	background: #e6e6e6;
}

#switch { display: none; }


label {
	float: left;
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	border-radius: 3vmin;
	padding: 0.25vmin;
	transform-style: preserve-3d;
	box-shadow: 0 0 0 1vmin #00000020 inset;
	cursor: pointer;
}


label:before {
	content: "";
	width: 10.5vmin;
	height: 20vmin;
	position: absolute;
	background: #333;
	z-index: 0;
	border-radius: 1vmin;
	left: 12.75vmin;
	top: 12vmin;
	box-sizing: border-box;
	box-shadow: -5px 0px 5px 0px #00000080 inset;
	transform: translateZ(1px);
}


label > span:nth-child(1):before, label > span:nth-child(1):after {
	content: "";
	width: 2vmin;
	height: 0.15vmin;
	position: absolute;
	top: 95%;
	left: 5vmin;
	border-radius: 100%;
	transform: rotateZ(0deg) rotateY(1deg) translate3d(0px, 0px, 1px);
	background: #3c3c3c;
	border-top: 1vmin solid #343434;
	border-bottom: 1vmin solid #343434;
	box-shadow: -1px -1px 1px 0px #23232380;
	transition: all 0.5s ease 0s;
}
 label > span:nth-child(1):after {
    transform: rotateZ(0deg) rotateY(-1deg) translate3d(23vmin, 0px, 1px);
}




input#switch:checked + .box label > span:nth-child(1):before,
input#switch:checked + .box label > span:nth-child(1):after {
	background: #eaeaea;
	border-top: 1vmin solid #a5a5a5;
	border-bottom: 1vmin solid #a5a5a5;
	box-shadow: -1px -1px 1px 0px #ffffff80;
	transition: all 0.5s ease 0s;
}







label > span {
	float: left;
	width: 100%;
	height: 50%;
	border-radius: 3vmin 3vmin 0 0;
	text-align: center;
	padding: 2vmin;
	perspective: 100vmin;
	transform-style: preserve-3d;
	font-family: Arial, Helvetica, serif;
	font-size: 4.5vmin;
	font-weight: bold;
	color: #4caf5040;
	text-shadow: 1px 1px 1px white;
	transition: all 0.5s ease 0s;
	color: #ffffff12;
	text-shadow: -1px -1px 1px #00000080;
}

label > span + span {
	border-radius: 0 0 3vmin 3vmin;
	text-align: center;
	padding-top: 14vmin;
	color: #ff000075;
	text-shadow: 1px 1px 1px #484848, -1px -1px 1px #4e0000;
	transform: translateZ(1px);
}


input#switch:checked + .box > label > span {
	color: #4caf50f5;	
	text-shadow: 1px 1px 1px white;
}

input#switch:checked + .box > label > span + span {
	color: #ff000040;	
	text-shadow: 1px 1px 1px white;
}


.cube-switch {
	border-radius: 0;
	position: absolute;
	left: 0;
	top: 18vmin;
	height: 8vmin;
	padding: 0;
	width: 8vmin;
	left: 14vmin;
	z-index: 0;
	transform-style: preserve-3d;
	perspective-origin: bottom;
	transform: translate3d(0, 0, -4vmin) rotateX(140deg);
	transform-origin: center center;
	transition: all 0.5s ease 0s;
}


input#switch:checked + .box > label > .cube-switch {
	transform: translate3d(0, 0, -4vmin) rotateX(220deg);
	transition: all 0.5s ease 0s;
}






label span > span {
	position: absolute;
	width: 200%;
	height: 100%;
	background: #333333;
	border: 1px solid #31313166;
	border-radius: 0.5vmin;
}


input#switch:checked + .box + label span > span {
	border: 1px solid #eaeaea66;
}


label > span span:nth-child(1) {
	transform: rotateX(0deg) translate3d(-4vmin, 0vmin, -14vmin);
	width: 100%;
	background: linear-gradient(160deg, #333 0% ,#333 23% , #121212);
}
label > span span:nth-child(2) {
	transform: rotateY(0deg) translate3d(-4vmin, 0vmin, 2vmin);
	width: 100%;
}
label > span span:nth-child(3) {
	transform: rotateX(-90deg) translate3d(-4vmin, 6vmin, 0vmin);
	width: 100%;
	height: 200%;
	background: linear-gradient(180deg, #333 0% ,#333 50% , #222);
}
label > span span:nth-child(4) {
	transform: rotateY(90deg) translate3d(6vmin, 0vmin, -4vmin);
}
label > span span:nth-child(5) {
	transform: rotateY(90deg) translate3d(6vmin, 0vmin, -12vmin);
	background: linear-gradient(125deg, #333 0% ,#333 50% , #222);
}
label > span span:nth-child(6) {
	transform: rotateX(-90deg) translat.........完整代码请登录后点击上方下载按钮下载查看

网友评论0