css+div实现亮色暗色按钮开关效果代码

代码语言:html

所属分类:布局界面

代码描述:css+div实现亮色暗色按钮开关效果代码

代码标签: css div 亮色 暗色 按钮 开关

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

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

<head>
  <meta charset="UTF-8">
  


  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
  
  
  
<style>
* {
	border: 0;
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
:root {
	--hue: 223;
	--fg: hsl(var(--hue),10%,10%);
	--trans-dur: 0.3s;
	--trans-timing: cubic-bezier(0.83, 0, 0.17, 1);
	font-size: calc(30px + (60 - 30) * (100vw - 320px) / (2560 - 320));
}
body,
input {
	color: var(--fg);
	font: 1em/1.5 sans-serif;
}
body {
	display: flex;
	height: 100vh;
}
main,
label,
.col {
	display: flex;
}
main {
	flex-direction: column;
	width: 100%;
}
label {
	align-items: center;
	margin: auto;
	-webkit-tap-highlight-color: transparent;
}
.col {
	background-color: hsl(var(--hue),10%,90%);
	background-image: linear-gradient(hsla(0,0%,0%,0),hsla(0,0%,0%,0.4));
	padding: 1.5em;
	width: 100%;
	height: 100%;
}
.sr {
	overflow: hidden;
	position: absolute;
	width: 1px;
	height: 1px;
}

/* Light theme */
.switch,
.switch__input {
	display: block;
}
.switch {
	border-radius: 1.5em;
	box-shadow: 0 0.125em 0.25em hsla(0,0%,0%,0.4);
	position: relative;
	width: 4.5em;
	height: 3em;
	perspective: 10em;
}
.switch span {
	display: block;
}
.switch > span {
	border-radius: inherit;
	z-index: 1;
}
.switch__surface-glare,
.switch__inner,
.switch__inner-glare,
.switch__rocker-sides,
.switch__rocker-sides-glare,
.switch__rocker,
.switch__rocker-glare,
.switch__ligh.........完整代码请登录后点击上方下载按钮下载查看

网友评论0