复制贴贴就能跑
复制就能跑,记得替换图片路径…
<html>
<head>
<meta charset="utf-8">
<script id="jqbb" src="https://libs.baidu.com/jquery/1.11.1/jquery.min.js">script>
<style type="text/css">
:root {
/* Base font size */
font-size: 10px;
/* Border color variable */
--border-color: #e70;
}
* {
box-sizing: border-box;
}
body {
font-family: "Montserrat", Arial, sans-serif;
font-weight: 500;
line-height: 1.5;
text-align: center;
min-height: 100vh;
padding: 4rem 2rem;
color: #fafafa;
background-color: #080808;
}
h1 {
font-size: 4rem;
}
h2 {
font-size: 2rem;
margin-bottom: 2.5rem;
}
.cube-container {
position: relative;
width: 30rem;
height: 30rem;
margin: 18rem auto 6rem;
perspective: 100rem;
}
.cube {
position: absolute;
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: transform 1s cubic-bezier(0.32, 0.05, 0.35, 1.6);
}
.cube-face-image {
display: block;
position: absolute;
/* opacity: 0.95; */
/* border: 0.2rem solid #fafafa; */
box-shadow: 0 0 0.5rem #fff, 0 0 1.5rem var(--border-color), 0 0 3rem var(--border-color);
}
.image-buttons {
display: grid;
grid-template-columns: repeat(3, auto);
grid-gap: 1.5rem;
justify-content: center;
}
.image-buttons input {
border: 0.2rem solid #fafafa;
}
.image-buttons input:focus {
outline: none;
border: 0.2rem solid var(--border-color);
}
/* Transform images to create cube */
.image-1 {
transform: translateZ(15rem);
}
.image-2 {
transform: rotateX(-180deg) translateZ(15rem);
}
.image-3 {
transform: rotateY(90deg) translateZ(15rem);
}
.image-4 {
transform: rotateY(-90deg) translateZ(15rem);
}
.image-5 {
transform: rotateX(90deg) translateZ(15rem);
}
.image-6 {
transform: rotateX(-90deg) translateZ(15rem);
}
/* Transform cube to show correct image */
.cube.initial-position {
transform: translateZ(-15rem) translateY(-2rem) rotateX(-15deg) rotateY(18deg) rotateZ(2deg);
}
.cube.show-image-1 {
transform: translateZ(-15rem);
}
.cube.show-image-2 {
transform: translateZ(-15rem) rotateX(180deg);
}
.cube.show-image-3 {
transform: translateZ(-15rem) rotateY(-90deg);
}
.cube.show-image-4 {
transform: translateZ(-15rem) rotateY(90deg);
}
.cube.show-image-5 {
transform: translateZ(-15rem) rotateX(-90deg);
}
.cube.show-image-6 {
transform: translateZ(-15rem) rotateX(90deg);
}
.image-buttons input {
width: 104px;
}
.clickText{
margin-top: 150px;
}
style>
head>
<body>
<div class="cube-container">
<div class="cube initial-position">
<img class="cube-face-image image-1" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/5568730.jpg">
<img class="cube-face-image image-2" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/1676626.jpg">
<img class="cube-face-image image-3" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/6765636.jpg">
<img class="cube-face-image image-4" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/4735676.jpg">
<img class="cube-face-image image-5" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/474001.jpg">
<img class="cube-face-image image-6" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/1363237.jpg">
div>
div>
<h2>Click the images below to rotate the cubeh2>
<div class="image-buttons">
<input type="image" class="show-image-1" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/5568730.jpg">input>
<input type="image" class="show-image-2" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/1676626.jpg">input>
<input type="image" class="show-image-3" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/6765636.jpg">input>
<input type="image" class="show-image-4" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/4735676.jpg">input>
<input type="image" class="show-image-5" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/474001.jpg">input>
<input type="image" class="show-image-6" src="https://www.jq22.com/demo/jQueryJdt201705310027/images/1363237.jpg">input>
div>
body>
<script>
//DOM load event
window.addEventListener("DOMContentLoaded", () => {
const cube = document.querySelector(".cube"),
imageButtons = document.querySelector(".image-buttons");
let cubeImageClass = cube.classList[1];
//Add click event listener to image buttons container
imageButtons.addEventListener("click", (e) => {
//Get node type and class value of clicked element
const targetNode = e.target.nodeName,
targetClass = e.target.className;
//Check if image input has been clicked and isn't the currently shown image
if (targetNode === "INPUT" && targetClass !== cubeImageClass) {
console.log(`Show Image: ${
targetClass.charAt(11)}`);
//Replace previous cube image class with new class
cube.classList.replace(cubeImageClass, targetClass);
//Update cube image class variable with new class
cubeImageClass = targetClass;
}
}, false);
}, false);
script>
html>
❤女朋友生日❤ HTML+css3+js 实现抖音炫酷樱花3D相册 (含背景音乐)程序员表白必备
❤七夕情人节❤html+css+js 漫天飞雪3D相册(含音乐自定义文字) 程序员表白必备
❤炫酷烟花表白❤ html+css+js 放一场浪漫烟花秀(含音乐) 程序员表白
❤唯美满天星❤ html+css+js炫酷3D相册(含音乐可自定义文字)程序员表白必备
新年祝福❤雪花飘落❤ html+css3+js 实现3D相册开关闭合旋转(情人节生日表白)必备
❤爱情墙❤html5+css3+js 实现全屏七夕表白页面 (可自定义文字相片)
❤[前端永久免费部署上线工具] 解决不需要服务器就能将项目部署上线问题!
❤超炫100套❤vue+echarts大屏可视化数据平台实战项目模板 (vuereact 均可使用)
抖音❤超火| html+css+js 流星雨3D相册(表白必备)制作教程来啦!
前端❤ html+css+js 实现1000个超炫酷特效(附源码)
web前端❤基于html+css+js 仿JD天猫电商平台功能齐全(免费附源码)
抖音超火❤ html+css+js 实现炫酷3D立方图像库(免费附源码)
抖音超火❤ html+css+js 实现炫酷3D魔方(免费附源码)
抖音超火❤流动爱心 html+css+js (免费附源码)
抖音超火❤罗盘时钟html+css+js (免费附源码)
亲测有效❤抖音视频去水印 ( 附源码| 仅供学习参考)
css3 实现3D旋转立方体(免费附源码)
css3 实现3D立体时钟(免费附源码)
❤雪花飘落❤ html+css+js实现2021新年倒计时特效(附源码)
这个冬天, 我是这样表白的 ❉html+css+js❉ 绘制冬季下雪3D相册 (521程序员表白代码大公开)
七夕情人节 ❤html+css+j❤实现满屏爱心特效(程序员表白)
❤html+css+js❤ 白云飘动3D相册(含音乐)程序员表白必备
一款乾坤八卦风水罗盘旋转CSS3动画,给人一种玄机重重的感觉(附源码)