HTML+CSS 3D旋转木马

HTML+CSS 3D旋转木马

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>旋转木马</title>
    <style>
        *{
            margin: 0;
            padding:0;
        }
        body{
            display: flex;
            justify-content: center;
            align-items: center;/*以上三行是旋转木马网页居中*/
            height: 100vh;/*高度占网页全部*/
            background-color: black;
            perspective: 900px;/*视距*/
        }
        section{
            position: relative;
            width: 300px;
            height: 200px;
            cursor: pointer;/*hover时鼠标箭头变手指*/
            transform-style: preserve-3d;/*写这个才能实现3d效果*/
            animation:rotate 20s linear infinite;
        }
        img{
            width: 300px;
            height: 200px;
        }
        section:hover{
            animation-play-state: paused;/*hover是旋转木马停止*/
        }
        section div{
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            text-align: center;
            -webkit-box-reflect:below 15px 
            -webkit-linear-gradient(transparent 10%,rgba(255,255,255,.3));
            /*实现倒影 below-倒影在原方块的下方  15px-原方块距离倒影的距离  倒影的10%设置为全透明, rgba设置剩下倒影的透明度*/
        }
        section div:nth-child(1){
            transform: translatez(300px);/*函数将元素从屏幕“向外”移动300像素到用户。这使得在2D显示器上观看时元素显得更大,*/
            background-color: #c14c39;
        }
        section div:nth-child(2){
            transform:rotateY(60deg) translatez(300px);/*rotateY表示绕y轴旋转60° */
            background-color: #6e9c72;
        }
        section div:nth-child(3){
            transform:rotateY(120deg) translatez(300px);
            background-color: #5e5f7a;
        }
        section div:nth-child(4){
            transform:rotateY(180deg) translatez(300px);
            background-color: #f5eb98;
        }
        section div:nth-child(5){
            transform:rotateY(240deg) translatez(300px);
            background-color: #50a3bc;
        }
        section div:nth-child(6){
            transform:rotateY(300deg) translatez(300px);
            background-color: #f9a99a;
        }
        @keyframes rotate {
            to{
                transform: rotateY(360deg);
            }
        }
    </style>
</head>
<body>
    <section>
        <div><img src="img2/1.jpg"></div>
        <div><img src="img2/2.jpg"></div>
        <div><img src="img2/3.jpg"></div>
        <div><img src="img2/4.jpg"></div>
        <div><img src="img2/5.jpg"></div>
        <div><img src="img2/6.jpg"></div>
    </section>
</body>
</html>

图片要自己加啊啊啊!
效果图视频我不会加。。。
有什么问题欢迎大家在评论区讨论!!

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Cwiyc

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

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

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

打赏作者

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

抵扣说明:

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

余额充值