js+css实现可调参数的3d倾斜图片卡片幻灯片效果代码

代码语言:html

所属分类:幻灯片

代码描述:js+css实现可调参数的3d倾斜图片卡片幻灯片效果代码,可修改光线颜色、密度、xyz轴。

代码标签: js css 参数 3d 倾斜 图片 卡片 幻灯片

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

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

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

  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  
  
  
<style>
*,
::after,
::before {
	border-style: solid;
	border-width: 0;
	box-sizing: border-box;
}

body {
	background-color: #121212;
	color: #fff;
	font-family: "Roboto", sans-serif;
	height: 100vh;
	overflow: hidden;
}

body,
img {
	margin: 0;
}

img {
	border: 0;
	color: transparent;
	display: block;
	font: 0/0 a;
	height: auto;
	outline: none;
	padding: 0;
	text-shadow: none;
	-webkit-user-select: none;
	-moz-user-select: none;
	user-select: none;
}

.wrapper,
img {
	position: relative;
}

.wrapper {
	align-items: center;
	height: 100%;
	justify-items: center;
	perspective: 1500px;
	width: 100%;
}

.stack {
	display: grid;
	grid-template-areas: "stack";
}

.stack > * {
	grid-area: stack;
}

.parallax-layer {
	aspect-ratio: 16/9;
	background: radial-gradient(
			circle,
			hsla(0, 0%, 100%, 0.1) 0,
			hsla(0, 0%, 100%, 0) 70%
		),
		repeating-linear-gradient(
			45deg,
			hsla(0, 0%, 100%, 0.1),
			hsla(0, 0%, 100%, 0.1) 0.625rem,
			rgba(0, 0, 0, 0.1) 0,
			rgba(0, 0, 0, 0.1) 1.25rem
		);
	border: 0.0625rem solid hsla(0, 0%, 100%, 0.1);
	border-radius: 1rem;
	display: block;
	max-width: 80rem;
	pointer-events: none;
	position: relative;
	transform-style: preserve-3d;
	transition: filter 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
	width: 100%;
}

.parallax-content {
	align-self: start;
	height: 100%;
	justify-self: start;
	opacity: 0.8;
	place-self: start;
	transform-origin: center center;
	width: 100%;
}

.parallax-content img {
	margin-left: 5%;
	margin-top: 5%;
	width: 30%;
}

.ambient-light-layer {
	display: block;
	height: 100%;
	mix-blend-mode: screen;
	pointer-events: none;
	position: relative;
	transition: background 0.2s ease-in-out, opacity 0.2s ease-in-out;
	width: 100%;
}

.carousel {
	aspect-ratio: 16/9;
	background-color: #000;
	border-radius: 1rem;
	max-width: 64rem;
	overflow: hidden;
	position: relative;
	transform-style: preserve-3d;
	width: 75%;
}

.slides-group {
	box-shadow: 0 0.3125rem 0.9375rem rgba(0, 0, 0, 0.2);
	transition: filter 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

.slide {
	display: block;
	opacity: 0;
	position: relative;
	transition: opacity 2s ease-in-out;
	width: 100%;
}

.slide img {
	animation: panRight 10s ease-in-out infinite;
	transform: translateZ(0);
	width: 110%;
}

.controls-layer {
	display: block;
	padding: 1rem;
	position: absolute;
	right: 0;
	top: 0;
	z-index: 100;
}

.controls {
	background: rgba(0, 0, 0, 0.7);
	border: 0.0625rem solid hsla(0, 0%, 100%, 0.1);
	border-radius: 0.5rem;
	display: flex;
	flex-direction: column;
	padding: 1rem;
	width: 100%;
	width: -moz-fit-content;
	width: fit-content;
}

.control-group,
.controls {
	display: flex;
	position: relative;
}

.control-group {
	flex-direction: column;
	height: 3rem;
}

label {
	display: block;
	font-size: 0.75rem;
	letter-spacing: 0.025rem;
	position: relative;
	-webkit-user-select: none;
	-moz-user-select: none;
	user-select: none;
}

label,
label ~ * {
	margin-bottom: auto;
}

label ~ * {
	margin-top: auto;
}

input[type="range"] {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background: hsla(0, 0%, 100%, 0.15);
	border-radius: 0.125rem;
	cursor: pointer;
	height: 0.25rem;
	outline: none;
	width: 9.375rem;
}

input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	background: #ef3a47;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	height: 1rem;
	-webkit-transition: background 0.3s ease;
	transition: background 0.3s ease;
	width: 1rem;
}

input[type="range"]::-webkit-slider-thumb:hover {
	background: #c6001c;
}

input[type="range"]::-moz-range-thumb {
	background: #ef3a47;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	height: 1rem;
	-moz-transition: background 0.3s ease;
	transition: background 0.3s ease;
	width: 1rem;
}
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0