首页 > 其他分享 >css旋转木马代码示例

css旋转木马代码示例

时间:2023-07-21 09:56:25浏览次数:39  
标签:木马 translateZ 示例 500px 100% transform rotateY background css


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        /*透视*/
        body {
            perspective: 1000px;
        }

        .box {
            position: relative;
            width: 300px;
            height: 200px;
            margin: 300px auto;
            /*子元素保持3D效果*/
            transform-style: preserve-3d;
            animation: rotate 20s linear infinite;
        }

        /*.box:hover {*/
        /*    animation-play-state: paused;*/

        /*}*/

        @keyframes rotate {
            0% {
            }
            100% {
                transform: rotateY(360deg);
            }
        }

        [class*="horse"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        .horse1 {
            background: url("./images/horse1.jpg") no-repeat;
            background-size: 100%;
            /*把正面的图像拉近一点,越靠近 眼睛*/
            transform: translateZ(500px);
        }

        .horse2 {
            background: url("./images/horse2.jpg") no-repeat;
            background-size: 100%;
            /*先转动,再移动*/
            transform: rotateY(60deg) translateZ(500px);
        }

        .horse3 {
            background: url("./images/horse3.jpg") no-repeat;
            background-size: 100%;
            transform: rotateY(120deg) translateZ(500px);
        }

        .horse4 {
            background: url("./images/horse4.jpg") no-repeat;
            background-size: 100%;
            transform: rotateY(180deg) translateZ(500px);
        }

        .horse5 {
            background: url("./images/horse5.jpg") no-repeat;
            background-size: 100%;
            transform: rotateY(240deg) translateZ(500px);
        }

        .horse6 {
            background: url("./images/horse6.jpg") no-repeat;
            background-size: 100%;
            transform: rotateY(300deg) translateZ(500px);
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="horse1"></div>
        <div class="horse2"></div>
        <div class="horse3"></div>
        <div class="horse4"></div>
        <div class="horse5"></div>
        <div class="horse6"></div>
    </div>
    
    <script>
        const horses = document.querySelectorAll('[class*=horse]')
        for (let i = 0; i < horses.length; i++) {
            horses[i].addEventListener('mouseenter', function () {
                this.style.transform = 'scale(3)'

            })
        }
        for (let i = 0; i < horses.length; i++) {
            horses[i].addEventListener('mouseleave', function () {
                // 鼠标离开后,还原成1倍,并且旋转角度、移动的位置都要还原
                //element.style.transform +=相当于给transform追加值
                this.style.transform = 'scale(1) '
                this.style.transform += `rotateY(${i * 60}deg)`
                this.style.transform += 'translateZ(500px)'


            })
        }
    </script>
</body>
</html>

标签:木马,translateZ,示例,500px,100%,transform,rotateY,background,css
From: https://www.cnblogs.com/bangbangzoutianya/p/17570451.html

相关文章

  • SQL函数大全及示例汇总及不同数据库之间的区别
    SQL函数大全及示例汇总概述SQL中包含以下七种类型的函数:聚合函数:返回汇总值。转型函数:将一种数据类型转换为另外一种。日期函数:处理日期和时间。数学函数:执行算术运算。字符串函数:对字符串、二进制数据或表达式执行操作。系统函数:从数据库返回在SQLSERVER中的值、对......
  • css
    /此文件不需要修改//层级://顶部菜单:98//顶部菜单上的列表:99//顶部菜单旁边的搜索框:100//侧边栏菜单:150//开启关闭侧边菜单的按钮:10000//隐藏/sideBarMain{display:none;}navigator{display:none;}blogTitleh1,#blogTitlea{/主标题/display:none;}blogTitleh2{......
  • Mybatis属性配置示例(properties)
    属性(properties)这些属性可以在外部进行配置,并可以进行动态替换。既可以在典型的Java属性文件中配置这些属性,也可以在properties元素的子元素中设置。参考官网:https://mybatis.net.cn/configuration.html#properties首先创建数据库配置文件db.propertiesdriver=com.mysql.c......
  • C语言 typedef的用法示例讲解
    typedef是在C和C++编程语言中的一个关键字,作用是为现有的数据类型(int、float、char……)创建一个新的名字,目的是为了使代码方便阅读和理解。一、什么是typedeftypedef是在C和C++编程语言中的一个关键字。作用是为现有的数据类型(int、float、char……)创建一个新的名字,目的是为了......
  • Factor语言编程示例
    目录语言简介示例语言简介https://rosettacode.org/wiki/Category:FactorFactor是一种基于堆栈的、串联的通用编程语言,注重实用性。Factor最初由SlavaPestov开发,于2003年作为一种为游戏编写的脚本语言诞生。该实现最初是用Java编写的解释器,但后来获得了优化编译器,并使......
  • CSSS属性overflow(溢出) 、CSS定位、JavaScript
    overflow溢出属性overflow(水平和垂直均设置)overflow-x(设置水平方向)overflow-y(设置垂直方向<title>溢出</title><style>div{text-indent:32px;border:5pxsolidred;height:400px;width:400px;/*overflow:hidden;*/......
  • javascript中map reduce filter的示例代码
    以下是JavaScript中map、reduce和filter的示例代码:Map(映射)示例代码:Map函数将数组中的每个元素映射为一个新的值,返回一个新的数组。constnumbers=[1,2,3,4,5];//将数组中的每个元素平方constsquaredNumbers=numbers.map(num=>num*num);console.log(square......
  • javascript中json 对象 数组之间相互转化的示例
    在JavaScript中,你可以使用JSON.stringify()将JSON对象转换为JSON字符串,使用JSON.parse()将JSON字符串转换为JSON对象。而要将JSON对象转换为数组,可以使用Object.values()方法,而要将数组转换为JSON对象,可以使用Array.reduce()方法。下面是这些转换的示例代码:将JSON对象转换为JSON......
  • 如何使用Apache服务器加载JS和CSS文件
    Apache服务器是一款常见的网页服务器软件,可以运行在多个操作系统下,如Linux、Unix、Windows等。对于网站开发者而言,如何使用Apache服务器来加载JS和CSS文件是一项非常重要的技能。在本文中,我们将为你介绍如何使用Apache服务器来加载JS和CSS文件。一、什么是JS和CSS文件JS文件是......
  • CSS3雪碧图 | 精灵图
    雪碧/精灵图CSSSprite也叫CSS精灵图、CSS雪碧图,是一种网页图片应用处理方式。它允许你将一个页面涉及到的所有零星图片都包含到一张大图中去为什么需要精灵图如果一个网页有很多小的背景图像作为修饰,当网页中的图像过多时,服务器就会频繁地接收和发送请求图片,造成服务器请求......