前端CSS3实现3D相册小案例

article/2025/10/12 12:45:20

前端CSS3实现3D相册小案例

HTML代码部分:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<title>3D相册</title> 
<link type="text/css" href="css/style.css" rel="stylesheet" />
<link href="css/index.css" rel="stylesheet" type="text/css">
</head> <body> 
<div class="box"> 
<ul class="minbox"> 
<li><img src="3D相册图片/01.jpg" width="100" height="100"></li> 
<li><img src="3D相册图片/02.jpg" width="100" height="100"></li> 
<li><img src="3D相册图片/03.jpg" width="100" height="100"></li> 
<li><img src="3D相册图片/04.jpg" width="100" height="100"></li> 
<li><img src="3D相册图片/05.jpg" width="100" height="100"></li> 
<li><img src="3D相册图片/06.jpg" width="100" height="100"></li> 
</ul> 
<ol class="maxbox"> 
<li><img src="3D相册图片/1.jpg" width="400" height="400"></li> 
<li><img src="3D相册图片/2.jpg" width="400" height="400"></li> 
<li><img src="3D相册图片/3.jpg" width="400" height="400"></li> 
<li><img src="3D相册图片/4.jpg" width="400" height="400"></li> 
<li><img src="3D相册图片/5.jpg" width="400" height="400"></li> 
<li><img src="3D相册图片/6.jpg" width="400" height="400"></li> 
</ol> 
</div> 
</body> 
</html> 

CSS部分代码:

@charset "utf-8";
*{margin:0;padding:0;
}
body{max-width: 100%;min-width: 100%;height: 100%;background-size: cover;background-repeat: no-repeat;background-attachment: fixed;background-size:100% 100%;position: absolute;margin-left: auto;margin-right: auto;
}
li{list-style: none;
}
.box{width:200px;height:200px;background-size: cover;background-repeat: no-repeat;background-attachment: fixed;background-size:100% 100%;position: absolute;margin-left: 42%;margin-top: 22%;-webkit-transform-style:preserve-3d;-webkit-transform:rotateX(13deg);-webkit-animation:move 5s linear infinite;
}
.minbox{width:100px;height:100px;position: absolute;left:50px;top:30px;-webkit-transform-style:preserve-3d;
}
.minbox li{width:100px;height:100px;position: absolute;left:0;top:0;
}
.minbox li:nth-child(1){background: url(../img/01.png) no-repeat 0 0;-webkit-transform:translateZ(50px);
}
.minbox li:nth-child(2){background: url(../img/02.png) no-repeat 0 0;-webkit-transform:rotateX(180deg) translateZ(50px);
}
.minbox li:nth-child(3){background: url(../img/03.png) no-repeat 0 0;-webkit-transform:rotateX(-90deg) translateZ(50px);
}
.minbox li:nth-child(4){background: url(../img/04.png) no-repeat 0 0;-webkit-transform:rotateX(90deg) translateZ(50px);
}
.minbox li:nth-child(5){background: url(../img/05.png) no-repeat 0 0;-webkit-transform:rotateY(-90deg) translateZ(50px);
}
.minbox li:nth-child(6){background: url(../img/06.png) no-repeat 0 0;-webkit-transform:rotateY(90deg) translateZ(50px);
}
.maxbox li:nth-child(1){background: url(../img/1.png) no-repeat 0 0;-webkit-transform:translateZ(50px);
}
.maxbox li:nth-child(2){background: url(../img/2.png) no-repeat 0 0;-webkit-transform:translateZ(50px);
}
.maxbox li:nth-child(3){background: url(../img/3.png) no-repeat 0 0;-webkit-transform:rotateX(-90deg) translateZ(50px);
}
.maxbox li:nth-child(4){background: url(../img/4.png) no-repeat 0 0;-webkit-transform:rotateX(90deg) translateZ(50px);
}
.maxbox li:nth-child(5){background: url(../img/5.png) no-repeat 0 0;-webkit-transform:rotateY(-90deg) translateZ(50px);
}
.maxbox li:nth-child(6){background: url(../img/6.png) no-repeat 0 0;-webkit-transform:rotateY(90deg) translateZ(50px);
}
.maxbox{width: 800px;height: 400px;position: absolute;left: 0;top: -20px;-webkit-transform-style: preserve-3d;}
.maxbox li{width: 200px;height: 200px;background: #fff;border:1px solid #ccc;position: absolute;left: 0;top: 0;opacity: 0.2;-webkit-transition:all 1s ease;
}
.maxbox li:nth-child(1){-webkit-transform:translateZ(100px);
}
.maxbox li:nth-child(2){-webkit-transform:rotateX(180deg) translateZ(100px);
}
.maxbox li:nth-child(3){-webkit-transform:rotateX(-90deg) translateZ(100px);
}
.maxbox li:nth-child(4){-webkit-transform:rotateX(90deg) translateZ(100px);
}
.maxbox li:nth-child(5){-webkit-transform:rotateY(-90deg) translateZ(100px);
}
.maxbox li:nth-child(6){-webkit-transform:rotateY(90deg) translateZ(100px);
}
.box:hover ol li:nth-child(1){-webkit-transform:translateZ(300px);width: 400px;height: 400px;opacity: 0.8;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(2){-webkit-transform:rotateX(180deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.8;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(3){-webkit-transform:rotateX(-90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.8;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(4){-webkit-transform:rotateX(90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.8;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(5){-webkit-transform:rotateY(-90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.8;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(6){-webkit-transform:rotateY(90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.8;left: -100px;top: -100px;
}
@keyframes move{0%{-webkit-transform: rotateX(13deg) rotateY(0deg);}100%{-webkit-transform:rotateX(13deg) rotateY(360deg);}
}

在这里插入图片描述


http://chatgpt.dhexx.cn/article/E1Ai4iRp.shtml

相关文章

制作一个简单3D相册

- 用到的点&#xff1a; 旋转 2D 旋转 transform: rotate(值deg) deg 角度的单位 3D 旋转 transform:rotateX rotateY roteteZ 如果让一个块实现3D效果&#xff0c;必须做两件事&#xff1a; 1、在要实现3D效果的块上 加transform-style:preserve-3D (声明) 2、在要实现3D效…

html结合css实现浏览器展示3D相册

最近写了一个在浏览器展示3D相册效果&#xff0c;通过html文件结合css实现。 1.html详细代码如下&#xff1a; <!DOCTYPE html> <html> <head> <meta charset"UTF-8"> <title>3D相册</title> <script src"../js/jquer…

python3d相册源代码_js和CSS3炫酷3D相册展示

js和CSS3炫酷3D相册展示 *{margin:0;padding:0;} body{background:url(img/bg.jpg);width:100%;height:100%;overflow:hidden;}; h1{width:277;height:76px;margin:30px auto 0;} .xc-3D{width:100%;height:300px;background:#fff;margin-top:100px;position:relative;transfor…

three.js 制作3D相册

效果图&#xff1a; 由于博客限制了图片大小&#xff0c;动画质量不太好&#xff0c; 在线效果&#xff1a; https://static-mp-df787464-d77c-4180-83c3-6e7add40073e.next.bspapp.com/ 参考了three.js 官方代码 <!-- 源码下载地址 https://pan.baidu.com/s/1AVB71Aj…

3d相册

页面脚本 我的图片是是本地的&#xff0c;大家可以放上自己喜爱的图片 <!DOCTYPE html> <html><head><meta charset"utf-8" /><title>3d相册</title></head><style>#box1 {/* 宽 */width: 300px;/* 高 */height: …

HTML实现3D相册

今天&#xff0c;我给大家分享一个3D相册的代码 废话不说先上效果图&#xff1a; 先新建两个文件夹&#xff0c;一个叫css&#xff0c;另一个叫img&#xff0c;如下图&#xff1a; 先新建一个文本文档&#xff0c;输入下面的代码&#xff1a; <!DOCTYPE html> <html…

教你零基础制作3D旋转相册(送给那个她~)

3D立体相册&#xff1f;   是的&#xff0c;相信大家或多或少的会在一些地方看到某些程序员用代码给自己女朋友写3D立体相册&#xff0c;那么你会不会也想自己手动敲出那些炫酷的代码呢&#xff1f;   那你是找对地方了。废话不多说&#xff0c;今天为大家分享利用html实现…

【3D相册】零基础完成3D相册并配上背景音乐

文章目录 一、前言二、准备工作1、新建文件夹2、准备素材对于图片的处理对于音乐的处理 三、代码工作1、python处理6张图片1.1代码运行1.2 放入背景图片 2、写html文件2.1 更换音乐素材 3、运行main.html 四、推荐阅读 一、前言 帮助好哥们整的一个小相册&#xff0c;给他写个…

斐波那契数列求和公式

斐波那契数列指的是这样一个数列&#xff1a;1、1、2、3、5、8、13、21、……    这个数列从第三项开始&#xff0c;每一项都等于前两项之和。它的通项公式为:(见下图)&#xff08;又叫“比内公式”&#xff0c;是用无理数表示有理数的一个范例。&#xff09; 斐波那契数列求…

斐波那契数列之python(5种方法)

斐波那契数列&#xff08;Fibonacci sequence&#xff09;&#xff0c;又称黄金分割数列、因数学家列昂纳多斐波那契&#xff08;Leonardoda Fibonacci&#xff09;以兔子繁殖为例子而引入&#xff0c;故又称为“兔子数列”&#xff0c;指的是这样一个数列&#xff1a;1、1、2、…

斐波那契数列(C/C++)

目录 背景介绍 解法1&#xff1a;非数组非递归 解法2&#xff1a;数组非递归 解法3&#xff1a;非数组递归 解法4&#xff1a;数组递归 背景介绍 斐波那契数列&#xff0c;又称黄金分割数列&#xff0c;指的是这样一个数列&#xff1a;0、1、1、2、3、5、8、13、21、34、…

关于斐波那契数列通项公式证明以及推广

在我们中学的时候老师都会举一个著名的兔子繁殖的例子&#xff1a;一般而言&#xff0c;兔子在出生两个月后&#xff0c;就有繁殖能力&#xff0c;一对兔子每个月能生出一对小兔子来。如果所有兔子都不死&#xff0c;那么一年以后可以繁殖多少对兔子&#xff1f;而这个问题就是…

斐波那契数列的四种解法

题目描述 斐波那契数列&#xff08;Fibonacci sequence&#xff09;&#xff0c;又称黄金分割数列&#xff0c;因数学家莱昂纳多斐波那契&#xff08;Leonardo Fibonacci&#xff09;以兔子繁殖为例子而引入&#xff0c;故又称为“兔子数列”&#xff0c;指的是这样一个数列&a…

斐波那契数列通项公式的求法

以下两种方法其实是一样的 1、方法一 其实所有人都知道T(n) T(n-1) T(n-2), T(1) T(2)1,T(n)也是一个斐波那契数列&#xff0c;求解时间复杂度的本质也就是求数列通项&#xff0c;结果MB的一个通项就把我难住了&#xff0c;只好回来google一下&#xff0c;把高中数学用的求…

【算法】斐波那契数列通项公式

特征方程和通项公式 如果数列 a n a_n an​的递推公式&#xff1a; a n c 1 a n − 1 c 2 a n − 2 a_nc_1a_{n-1}c_2a_{n-2} an​c1​an−1​c2​an−2​------(1) 根据待定系数法&#xff0c;假设 a n − x a n − 1 y ( a n − 1 − x a n − 2 ) a_n-xa_{n-1}y(a_{n-1…

斐波那契数列通项公式的推导证明----举一反三

斐波那契数列通项公式的推导证明----举一反三 1-前言2-斐波那契2-1-什么是斐波那契2-2-通项公式的证明2-3-举一反三 1-前言 2021年5月20号的那天&#xff0c;有对象的都忙着约会秀恩爱&#xff0c;而我这样的单身狗&#xff0c;只能自己学习沉淀自己&#xff0c;为梦想而奔波&a…

七种方式求斐波那契(Fibonacci)数列通项

一&#xff1a;递归实现   使用公式f[n]f[n-1]f[n-2]&#xff0c;依次递归计算&#xff0c;递归结束条件是f[1]1&#xff0c;f[2]1。 二&#xff1a;数组实现   空间复杂度和时间复杂度都是0(n)&#xff0c;效率一般&#xff0c;比递归来得快。 三&#xff1a;vector<in…

响应式 - 基于尺寸的响应式内边距

前言 为了衬托一个响应式宽度的图像元素&#xff0c;需要添加相对的内边距。如果使用静态的宽度内边距&#xff0c;图像内边距在较小的浏览器窗口中可能会显得过大&#xff0c;从而与其他附近元素相互挤压&#xff0c;甚至可能将图像挤出屏幕。 准备工作 理解盒模型属性的计算…

响应式 - 基于min-width和max-width属性的响应式布局

前言 响应式布局的很多解决方案都相当复杂&#xff0c;但是本节中的方法却非常简单。该方法通过在3个浮动元素上设置min-width和max-width属性来实现响应式布局。只要采用CSS中这个非常简单的响应式布局特性&#xff0c;就能够适应移动设备和不同尺寸的计算机屏幕。 准备工作 …