炫酷的3D相册

3D相册

使用html+css制作一个独属于自己的炫酷相册

图片超过六张的可自行修改样式调整角度和大小
背景样式未写入,需要可查看背景渐变动画

3D相册

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
<div class="box1">
    <ul class="minbox1">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <ul class="minbox2">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>
</body>
</html>
.box1 {
    position: relative;
    width: 500px;
    height: 500px;
    margin: 200px auto;
    transform-style: preserve-3d;
    animation: move1 10s infinite linear;
}

ul {
    list-style: none;
}

/* 内盒子样式 */
.minbox1 {
    width: 250px;
    height: 250px;
    position: absolute;
    margin: 125px;
    transform-style: preserve-3d;
}
.minbox1 li {
    width: 250px;
    height: 250px;
    position: absolute;
}

.minbox1 li:nth-child(1) {
    background: url("./img/01.jpg") no-repeat;
    background-size: cover;
    transform: translateZ(125px);
    transition: transform 1.5s;          /* 鼠标离开样式还原时所需的时间 */
}
.minbox1 li:nth-child(2) {
    background: url("./img/02.jpg") no-repeat;
    background-size: cover;
    transform: rotateY(90deg) translateZ(125px);
    transition: transform 1.5s;
}
.minbox1 li:nth-child(3) {
    background: url("./img/03.jpg") no-repeat;
    background-size: cover;
    transform: rotateX(90deg) translateZ(125px);
    transition: transform 1.5s;
}
.minbox1 li:nth-child(4) {
    background: url("./img/04.jpg") no-repeat;
    background-size: cover;
    transform: rotateX(180deg) translateZ(125px);
    transition: transform 1.5s;
}
.minbox1 li:nth-child(5) {
    background: url("./img/05.jpg") no-repeat;
    background-size: cover;
    transform: rotateY(-90deg) translateZ(125px);
    transition: transform 1.5s;
}
.minbox1 li:nth-child(6) {
    background: url("./img/06.jpg") no-repeat;
    background-size: cover;
    transform: rotateX(-90deg) translateZ(125px);
    transition: transform 1.5s;
}


/*外盒子样式*/
.minbox2 {
    line-height: 500px;
    width: 500px;
    height: 500px;
    position: absolute;
    margin: auto;
    transform-style: preserve-3d;
}
.minbox2 li {
    width: 500px;
    height: 500px;
    position: absolute;
    opacity: 0.5;
}
.minbox2 li:nth-child(1) {
    background: url("./img/01.jpg") no-repeat;
    background-size: cover;
    transform: translateZ(220px);
    transition: transform 1.5s;
}
.minbox2 li:nth-child(2) {
    background: url("./img/02.jpg") no-repeat;
    background-size: cover;
    transform: rotateY(90deg) translateZ(220px);
    transition: transform 1.5s;
}
.minbox2 li:nth-child(3) {
    background: url("./img/03.jpg") no-repeat;
    background-size: cover;
    transform: rotateX(90deg) translateZ(220px);
    transition: transform 1.5s;
}
.minbox2 li:nth-child(4) {
    background: url("./img/04.jpg") no-repeat;
    background-size: cover;
    transform: rotateX(180deg) translateZ(220px);
    transition: transform 1.5s;
}
.minbox2 li:nth-child(5) {
    background: url("./img/05.jpg") no-repeat;
    background-size: cover;
    transform: rotateY(-90deg) translateZ(220px);
    transition: transform 1.5s;
}
.minbox2 li:nth-child(6) {
    background: url("./img/06.jpg") no-repeat;
    background-size: cover;
    transform: rotateX(-90deg) translateZ(220px);
    transition: transform 1.5s;
}


/* 鼠标悬停时动画改变 */
.box1:hover {
    animation: move2 8s infinite linear;
}
/* 鼠标悬停时内盒子样式 */
.box1:hover .minbox1 li:nth-child(1) {
    transform: translateZ(200px);
    transition: transform 1s;          /* 鼠标悬停时样式变化所需的时间 */
}
.box1:hover .minbox1 li:nth-child(2) {
    transform: rotateY(90deg) translateZ(150px);
    transition: transform 1s;
}
.box1:hover .minbox1 li:nth-child(3) {
    transform: rotateX(90deg) translateZ(150px);
    transition: transform 1s;
}
.box1:hover .minbox1 li:nth-child(4) {
    transform: rotateX(180deg) translateZ(150px);
    transition: transform 1s;
}
.box1:hover .minbox1 li:nth-child(5) {
    transform: rotateY(-90deg) translateZ(150px);
    transition: transform 1s;
}
.box1:hover .minbox1 li:nth-child(6) {
    transform: rotateX(-90deg) translateZ(150px);
    transition: transform 1s;
}
/* 鼠标悬停时外盒子样式 */
.box1:hover .minbox2 li:nth-child(1) {
    transform: translateZ(600px);
    transition: transform 2s;
}
.box1:hover .minbox2 li:nth-child(2) {
    transform: rotateY(60deg) translateZ(600px);
    transition: transform 2s;
}
.box1:hover .minbox2 li:nth-child(3) {
    transform: rotateY(120deg) translateZ(600px);
    transition: transform 2s;
}
.box1:hover .minbox2 li:nth-child(4) {
    transform: rotateY(180deg) translateZ(600px);
    transition: transform 2s;
}
.box1:hover .minbox2 li:nth-child(5) {
    transform: rotateY(-120deg) translateZ(600px);
    transition: transform 2s;
}
.box1:hover .minbox2 li:nth-child(6) {
    transform: rotateY(-60deg) translateZ(600px);
    transition: transform 2s;
}

@keyframes move1 {
    0% {
        transform: rotateX(10deg) rotateY(0deg);
    }
    100% {
        transform: rotateX(370deg) rotateY(360deg);
    }
}

@keyframes move2 {
    0% {
        transform: rotateX(20deg) rotateY(0deg);
    }
    100% {
        transform: rotateX(20deg) rotateY(360deg);
    }
}

gitee源代码下载:https://gitee.com/xie-xiaochun/album.git

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

呦呀

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值