2021-07-18

过渡

  • 通过过渡可以指定一个属性发生变化时的切换方式
  • 通过过渡可以创建一些非常好的效果,提升用户的体验
1.transition-property:指定要执行过渡的属性

多个属性间使用,隔开
如果所有属性都需要过渡,则使用all关键字
大部分属性都支持过渡效果,注意过渡时必须时从一个有效数值向另外一个有效数值进行过渡

2.transition-duration:指定过渡效果的持续时间

时间单位:s 和 ms 1s = 1000ms

3. transition-timing-function: 过渡的时序函数

指定过渡的执行的方式
可选值:
ease 默认值,慢速开始,先加速,再减速
linear 匀速运动
ease-in 加速运动
ease-out 减速运动
ease-in-out 先加速 后减速
cubic-bezier() 来指定时序函数
http://cubic-bezier.com
steps() 分步执行过渡效果
可以设置一个第二个值:
end ,在时间结束时执行过渡(默认值)
start ,在时间开始时执行过渡

4. transition-delay:过渡效果的延迟,等待一段时间后再执行过渡

米兔的动画

<!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>Document</title>
    <style>
        .box1{
            height:132px ;
            width: 64px;
            margin: 0 auto;
            background-image: url(./img/11/bigtap-mitu-queue-big.png);
            background-position: 0 0;
            transition: 0.3s steps(3);
        }

        .box1:hover{
            background-position: -192px 0;
        }
    </style>
</head>
<body>

    <div class="box1"></div>
    
</body>
</html>

动画

1.animation-name:要对当前元素生效的关键帧名字
2.animation-duration:动画的执行时间
3.animation-delay: 动画的延时
4.animation-iteration-count : 动画执行的次数

可选值:
次数
infinite 无限执行

5.animation-direction: 指定动画运行的方向

可选值:
normal 默认值 从 from 向 to运行 每次都是这样
reverse 从 to 向 from 运行 每次都是这样
alternate 从 from 向 to运行 重复执行动画时反向执行
alternate-reverse 从 to 向 from运行 重复执行动画时反向执行

6.animation-paly-state:设置动画的执行状态

可选值:
running 默认值 动画执行
paused 动画暂停

7.animation-fill-mode: 动画的填充模式

可选值:
none 默认值 动画执行完毕元素回到原来位置
forwards 动画执行完毕元素会停止在动画结束的位置
backwards 动画延时等待时,元素就会处于开始位置
both 结合了forwards 和 backwards

奔跑的少年

<!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>Document</title>
    <style>
        .box1{
            width: 100px;
            height: 102px;
            margin: 0 auto;
            background-image: url(./img/12/bg2.png);
            animation: run 1s steps(6) infinite;
        }

        /* 创建关键帧 */
        @keyframes run{
            from{
                background-position: 0 0;
            }

            to{
                background-position: -597px 0;
            }
        }
    </style>
</head>
<body>

    <div class="box1"></div>
    
</body>
</html>

关键帧

<!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>Document</title>
    <style>
        
        .outer{
            height: 500px;
            border-bottom: 10px black solid;
            margin: 50px auto;
            overflow: hidden;
        }

        .outer div{
            float: left;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background-color: #bfa;

            animation: ball .5s forwards linear infinite alternate;
        }

        div.box2{
            background-color: orange;
            animation-delay: .1s;
        }

        div.box3{
            background-color: yellow;
            animation-delay: .2s;
        }

        div.box4{
            background-color: yellowgreen;
            animation-delay: .3s;
        }

        div.box5{
            background-color: blue;
            animation-delay: .4s;
        }

        div.box6{
            background-color: pink;
            animation-delay: .5s;
        }

        div.box7{
            background-color: tomato;
            animation-delay: .6s;
        }

        div.box8{
            background-color: skyblue;
            animation-delay: .7s;
        }

        div.box9{
            background-color: chocolate;
            animation-delay: .8s;
        }



        /* 创建小球下落的动画 */
        @keyframes ball{
            from{
                margin-top: 0;
            }

            to{
                margin-top: 400px;
            }
        }
    </style>
</head>
<body>

    <div class="outer">
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
        <div class="box4"></div>
        <div class="box5"></div>
        <div class="box6"></div>
        <div class="box7"></div>
        <div class="box8"></div>
        <div class="box9"></div>
    </div>
    
</body>
</html>

在这里插入图片描述

变形

变形就是指通过CSS来改变元素的形状或位置
- 变形不会影响到页面的布局
- transform 用来设置元素的变形效果
- 平移:
translateX()沿着x轴方向平移
translateY()沿着y轴方向平移
translateZ()沿着z轴方向平移
- 平移元素,百分比是相对于自身计算的

<!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>Document</title>
    <style>
        body{
            background-color: rgb(236, 236, 236);
        }
        .box1{
            width: 200px;
            height: 200px;
            background-color: #bfa;
            margin: 0 auto;
            margin-top: 200px;
        }

        .box3{
            background-color: orange;
            position:absolute;
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
        }

        .box4, .box5{
            width: 220px;
            height: 300px;
            background-color: #fff;
            float: left;
            margin: 0 10px; 
            transition: all .3s;

        }
        .box4:hover,.box5:hover{
            transform: translateY(-4px);
            box-shadow: 0 0 10px rgba(0, 0, 0, .3);
        }
    </style>
</head>
<body>

    <div class="box1"></div>
    
    <div class="box2"></div>

    <!-- <div class="box3">aaaa</div> -->

    <div class="box4"></div>

    <div class="box5"></div>
</body>
</html>

在这里插入图片描述

z轴平移

1.z轴平移,调整元素在z轴的位置,正常情况就是调整元素和人眼之间的距离,距离越大,元素离人越近
2.z轴平移属于立体效果(近大远小),默认情况下网页是不支持透视,如果需要看见效果,必须要设置网页的视距

旋转

1.通过旋转可以使元素沿着x y 或 z旋转指定的角度

rotateX()
rotateY()
rotateZ()

2.是或否显示元素的背面

backface-visibility: hidden;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值