css3 3D立体相册实现

article/2025/8/23 21:05:11

        这几天无聊,看到有博主弄的电子相册有点意思,就照葫芦画瓢也实现了一个,一个半透明的正方体包含着一个小正方体,相册自动旋转,当获得焦点时变化效果,截图如下:

 

 

 

一,代码目录结构

二,html代码

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>3D立体相册</title>
<link type="text/css" href="css/style.css" rel="stylesheet" />
</head>
<body>
<div class="box"><ul class="minbox"><!-- 内层 --><li></li><li></li><li></li><li></li><li></li><li></li></ul><ol class="maxbox"><!-- 外层 --><li></li><li></li><li></li><li></li><li></li><li></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;background: url(../img/bj1.png) no-repeat 0 0;
}
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 10s 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.jpg) no-repeat 0 0;background-size:100px 100px;-webkit-transform:translateZ(50px);
}
.minbox li:nth-child(2){background: url(../img/02.jpg) no-repeat 0 0;background-size:100px 100px;-webkit-transform:rotateX(180deg) translateZ(50px);
}
.minbox li:nth-child(3){background: url(../img/03.jpg) no-repeat 0 0;background-size:100px 100px;-webkit-transform:rotateX(-90deg) translateZ(50px);
}
.minbox li:nth-child(4){background: url(../img/04.jpg) no-repeat 0 0;background-size:100px 100px;	-webkit-transform:rotateX(90deg) translateZ(50px);
}
.minbox li:nth-child(5){background: url(../img/05.jpg) no-repeat 0 0;background-size:100px 100px;	-webkit-transform:rotateY(-90deg) translateZ(50px);
}
.minbox li:nth-child(6){background: url(../img/06.jpg) no-repeat 0 0;background-size:100px 100px;	-webkit-transform:rotateY(90deg) translateZ(50px);
}
.maxbox li:nth-child(1){background: url(../img/01.jpg) no-repeat 0 0;background-size:400px 400px;	-webkit-transform:translateZ(50px);
}
.maxbox li:nth-child(2){background: url(../img/02.jpg) no-repeat 0 0;background-size:400px 400px;	-webkit-transform:rotateX(180deg) translateZ(50px);
}
.maxbox li:nth-child(3){background: url(../img/03.jpg) no-repeat 0 0;background-size:400px 400px;	-webkit-transform:rotateX(-90deg) translateZ(50px);
}
.maxbox li:nth-child(4){background: url(../img/04.jpg) no-repeat 0 0;background-size:400px 400px;	-webkit-transform:rotateX(90deg) translateZ(50px);
}
.maxbox li:nth-child(5){background: url(../img/05.jpg) no-repeat 0 0;background-size:400px 400px;	-webkit-transform:rotateY(-90deg) translateZ(50px);
}
.maxbox li:nth-child(6){background: url(../img/06.jpg) no-repeat 0 0;background-size:400px 400px;	-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.9;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(2){-webkit-transform:rotateX(180deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.9;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(3){-webkit-transform:rotateX(-90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.9;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(4){-webkit-transform:rotateX(90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.9;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(5){-webkit-transform:rotateY(-90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.9;left: -100px;top: -100px;
}
.box:hover ol li:nth-child(6){-webkit-transform:rotateY(90deg) translateZ(300px);width: 400px;height: 400px;opacity: 0.9;left: -100px;top: -100px;
}
@keyframes move{0%{-webkit-transform: rotateX(13deg) rotateY(0deg);}100%{-webkit-transform:rotateX(13deg) rotateY(360deg);}
}

页面上可能出现图片倒置的情况,我文件夹里面把图片旋转即可;

代码下载路径:https://gitee.com/zhaoHengCodes/html

 


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

相关文章

3D立体相册 html+css

前言 用css的transform属性做一个3D相册~~~ 值translate表示偏移&#xff1b; scale表示缩放&#xff1b; rotate就是转动。 一、先看效果 二、实现步骤 1.我们知道一个正方体有6个面&#xff0c;所以定义一个父亲元素然后定义6个子元素作为6个面。每个面放一张图片。里面q1…

搭载3D立体相册网页 加入背景音乐 真香!

一、3D立体相册 HTML代码 <!DOCTYPE html> <html lang="en"><head><meta

七夕表白程序:3D 立体表白相册(素材+源码),用它的都成功了!

马上就要七夕了&#xff0c;学编程的你没有什么拿得出手的礼物吗&#xff1f;不如用我们所学知识来做个简单的 3D 立体表白相册吧&#xff01;&#xff08;特效绝对杠杠的&#xff09; 希望大家&#xff08;以及大家的那一位&#xff09;喜欢! 效果截图如下&#xff1a;&…

抖音上很火的3D立体动态相册

带背景音乐网站效果: http://www.fengzhao.icu/photos/html/%E6%8A%96%E9%9F%B3%E4%B8%8A%E5%BE%88%E7%81%AB%E7%9A%843D%E7%AB%8B%E4%BD%93%E5%8A%A8%E6%80%81%E7%9B%B8%E5%86%8C.html 如何创建网站:参考我的这篇文章 https://blog.csdn.net/allen_csdns/article/details…

【Python入门】Python做游戏——跳跃小鸟

如何运行 安装依赖pip install keras pip install pygame pip install scikit-image pip install h5py作者使用的是theano训练的,训练好的模型文件要使用theano作为Keras的后端才能调用,在配置文件~/.keras/keras.json中(没有可创建)确认/修改backend为theano(如果没有安装…

教你用Python做小游戏

第一步&#xff1a;你好&#xff0c;兔子 运行IDLE&#xff0c;打开一个新的文本编辑窗口。输入以下的代码&#xff1a; # 1 - Import library import pygame from pygame.locals import *# 2 - Initialize the game pygame.init() width, height 640, 480 screenpygame.dis…

怎么用python做游戏_如何用python做游戏

你有没有想过电脑游戏是怎样制作出来的&#xff1f;其实它没有你想象的那样复杂&#xff01; PyGame是一个Python的库&#xff0c;能够让你更容易的写出一个游戏。它提供的功能包括图片处理和声音重放的功能&#xff0c;并且它们能很容易的整合进你的游戏里。去官网点击这里下载…

为了上班摸鱼我用Python制作十五个小游戏,普通到地狱级难度,看看你能挑战到哪【内附源码】

今天给大家带来十五个Python小游戏&#xff0c;找回童年的同时学习编程还可以摸鱼&#xff0c;源码附上结尾领取。 一、接金币&#xff08;1分&#xff09; 普通难度&#xff1a;❤ 玩法介绍&#xff1a; 吃金币&#xff0c;控制左右键&#xff0c;有手就行。 ​ 源码分享…

用python做一个简单的游戏,用python写一个小游戏

大家好&#xff0c;本文将围绕如何用python做一个简单的小游戏展开说明&#xff0c;python编写的入门简单小游戏是一个很多人都想弄明白的事情&#xff0c;想搞清楚用python做一个简单的游戏需要先了解以下几个事情。 1、Python游戏开发&#xff0c;Python实现贪吃蛇小游戏与吃…

用 Python 做游戏有多简单

大家好&#xff0c;今天我用两篇文章来介绍一下&#xff0c;如果使用 Python 做游戏。 这个游戏是使用 PyGame 做的&#xff0c;贴图素材是从 itch.io[1] 找的。我之前也没有用过 PyGame&#xff0c;这次属于是现学现用&#xff0c;参考的教程是 PyGame: A Primer on Game Prog…

Python做游戏其实很简单,只是你觉得难...

很多小伙伴都喜欢小游戏源码&#xff0c;想学一手Python做小游戏&#xff0c;问我做游戏难不难&#xff0c;要怎么做&#xff0c;接下来我就介绍一下&#xff0c;如何用Python做游戏。 游戏演示 2048小游戏 表白弹窗 贪吃蛇 五子棋 俄罗斯方块 超多小游戏&#xff0c;让你一个…

Python不能做游戏?一小时做出一个游戏!

嗨喽&#xff5e;小伙伴们&#xff0c;我又来了&#xff0c; 写在前面的话&#xff1a; 【 一直都听他们说&#xff0c;python做不出好的游戏&#xff0c;个人是不赞同的&#xff0c;我只能说&#xff0c;python可以用来写游戏&#xff0c;但不适合。 举个最简单的例子&…

【含源码】用python做游戏有多简单好玩

有很多同学问我还有其他什么小游戏吗&#xff0c;游戏是怎么做的&#xff0c;难不难。我就用两篇文章来介绍一下&#xff0c;如何使用Python做游戏。 兔子与灌 俄罗斯方块 休闲五子棋 走迷宫 推箱子 消消乐 超多小游戏玩转不停↓ 更多小游戏可以评论区讨论哦&#xff0c;喜欢…

python做小游戏之一小迷宫游戏

趣味python一迷宫小游戏 读取外部迷宫地图 既然是编写小游戏&#xff0c;那么自然少不了pygame模块&#xff0c;编译环境使用的是pycharm。 迷宫小游戏设计思想是&#xff0c;我们自己绘制迷宫地图文档&#xff0c;然后程序根据我们设计的地图把迷宫绘制到pygame游戏界面当中来…

一日一技:用Python做游戏有多简单 (2)

现在用Python来制作游戏越来越方便&#xff0c;虽然某些方面有所限制。但是利用Pygame工具包基本能制作所有的2D游戏在制作的同时对游戏的理解也会更加深刻&#xff0c;因为本质上都是对图片的定位和图片碰撞的判断&#xff0c;从而以此为原理衍生出各种各样的游戏类型。 接下…

一日一技:用Python做游戏有多简单

自从表白代码发了以后&#xff0c;有很多同学问我除了这种表白的&#xff0c;还有其他什么小游戏吗&#xff0c;游戏是怎么做的&#xff0c;难不难。我就用两篇文章来介绍一下&#xff0c;如果使用Python做游戏。 兔子与灌 俄罗斯方块 休闲五子棋 走迷宫 推箱子 消消乐 超多小…

利用python制作自己的小游戏,超简教程

懒得客套&#xff0c;直接步入主题 首先&#xff0c;利用python来做游戏需要用到python中的pygame模块&#xff0c;这个我们在终端cmd中安装 输入&#xff1a;pip install pygame 安装好后我们进入pycharm查询我们有的模块&#xff08;打开路径&#xff1a;文件-设置&#xf…

如何用python做游戏(简单易上手版)【送 源码】

嗨害大家好鸭&#xff0c;我是小熊猫&#x1f5a4; 很多小伙伴后台私信问我说&#xff0c; “python可以做游戏吗 &#xff1f;” “要怎么做呢&#xff1f;” 接下来我就介绍一下&#xff0c; 如何用Python做游戏 有什么python相关报错解答自己不会的、或者源码资料/模块…

python小游戏-移动木板

文章目录 一、游戏简介二、编写步骤1.引入库2.初始化3.相关自定义函数4.相关自定义函数 一、游戏简介 本游戏是通过python编写的小游戏&#xff0c;给初学者熟悉python编程语言抛砖引玉&#xff0c;希望有所帮助。 成型的效果图如下&#xff1a; 二、编写步骤 1.引入库 代码…

UDP over Socks5 实现全局透明代理

Socks5代理协议很强大&#xff0c;不光可以实现HTTP/HTTPS代理的TCP隧道代理功能&#xff0c;类似connect&#xff0c;还可以实现HTTP代理不能做到的UDP代理功能。 要知道UDP代理的重要过程&#xff0c;以方便我们排查错误&#xff0c;我们还需要了解Socks5协议对UDP代理方式的…