range实现推石头上山黑夜白昼切换效果代码

代码语言:html

所属分类:其他

代码描述:range实现推石头上山黑夜白昼切换效果代码,鼠标点击拖动石头试试。

代码标签: range 石头 上山 黑夜 白昼 切换

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

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

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

  
  
  
<style>
@import url("https://fonts.cdnfonts.com/css/spartacus-2");

*,
*:before,
*:after {
	box-sizing: border-box;
}

html,
body {
	background: #222;
	padding: 0;
	margin: 0;
	display: flex;
	min-height: 100%;
	width: 100%;
	align-items: center;
	justify-content: center;
}

.demo {
	--sky: #010015;
	position: relative;
	height: 379px;
	border-radius: 10px;
	width: 100%;
	max-width: 768px;
	margin: auto;
	overflow: hidden;
	background: var(--sky);
	transition: 0.3s background ease;
	font-family: "", sans-serif;
	user-select: none;

	@media screen and (max-width: 768px) {
		border-radius: 0;
	}
}

input[type="range"] {
	position: absolute;
	left: 1%;
	bottom: 10%;
	-webkit-appearance: none;
	background: transparent;
	height: 0;
	width: 80%;
	min-width: 300px;
	rotate: -90deg;
	transform-origin: left top;
	z-index: 5;

	@media screen and (max-width: 768px) {
		left: 2%;
		width: 70%;
	}

	&:focus-visible {
		outline: none;

		&::-webkit-slider-thumb {
			border: 6px solid #99c8ff;
		}
	}
}

input[type="range"]::-webkit-slider-runnable-track {
	background: rgba(0 0 0 / 0.1);
	height: 5px;
	border-top-left-radius: 100%;
	border-bottom-right-radius: 100%;
}

input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	width: 70px;
	height: 70px;
	margin-top: -65px;
	background: #332622;
	border: 6px solid #523e37;
	border-radius: 50%;
	cursor: grab;
	rotate: calc(var(--factor) * 0.3deg);
	box-shadow: -14px -14px 0 0px #44342e inset, -14px 14px 0 0px #3f302b inset,
		21px 0 0 0px #3a2c27 inset;
	clip-path: polygon(
		19% 91%,
		43% 99%,
		73% 94%,
		94% 75%,
		100% 47%,
		94% 22%,
		75% 5%,
		50% 1%,
		22% 8%,
		5% 27%,
		0 55%,
		4% 75%
	);
}

/* landscape */
.mountains {
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	z-index: 10;
	z-index: 2;
}

.mountain {
	position: absolute;
	inset: auto auto 0 var(--position);
	overflow: hidden;
	border-top-left-radius: 10px;
	width: calc(var(--size) * 1.4);
	height: calc(var(--size) * 1.4);
	transform: translate(0, 50%) rotate(45deg);
	z-index: var(--z);
	box-shadow: 2px 0 10px 0 rgba(0 0 0 / 0.4);
	transition: 0.3s box-shadow ease;
}

.mountain:before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	background: #fff;
	--pike: calc(var(--size) / 18);
	--n-pike: calc(var(--size) / -12);
	box-shadow: var(--pike) var(--n-pike) 0 0 #fff,
		var(--n-pike) var(--pike) 0 0 #fff,
		calc(var(--pike) * 2) calc(var(--n-pike) * 2) 0 0 #fff,
		calc(var(--n-pike) * 2) calc(var(--pike) * 2) 0 0 #fff,
		calc(var(--pike) * 2.75) calc(var(--n-pike) * 2.75) 0 0 #fff,
		calc(var(--n-pike) * 2.75) calc(var(--pike) * 2.75) 0 0 #fff;
	width: calc(var(--size) / 4);
	height: calc(var(--size) / 4);
	z-index: 20;
	filter: drop-shadow(0 0 5px rgba(0 0 0 / 0.3));
}

.mountain:after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(0deg, #ba7888 0%, #803848 100%);
	box-shadow: calc(var(--size) / 4.66) calc(var(--size) / 7) 0 0
			rgba(0 0 0 / 0.05) inset,
		calc(var(--size) / 4.66) 0 0 0 rgba(255 255 255 / 0.09) inset;
}

.mountain--1 {
	--position: 10%;
	--size: 200px;
	--z: 5;
	--scaleY: 0.5;

	@media screen and (max-width: 768px) {
		--position: -2.........完整代码请登录后点击上方下载按钮下载查看

网友评论0