css3过渡和动画知识点

该博客展示了两个CSS动画示例,案例一利用`@keyframes`创建了一个圆形颜色和位置变化的动画效果;案例二则通过相对定位和动画实现了元素在矩形区域内移动并改变形状和颜色的效果。这两个案例详细解释了CSS动画和相对定位的应用。
摘要由CSDN通过智能技术生成

案例一:

.nav{
            /*width: 200px;
            height: 200px;
            background-color: orange;
            border-radius: 50%;*/
            animation: yidong  infinite 10s alternate;
        }
        @keyframes yidong{
            0%{
                width: 200px;
                height: 200px;
                margin-left: 0%;
                border-radius: 50%;
                background-color:  orange;
                
            }
            50%{
                width: 200px;
                height: 200px;
                margin-left: 45%;
                border-radius: 0;
                background-color: yellow;
                
            }
            100%{
                width: 200px;
                height: 200px;
                margin-left: 87%;
                background-color: cornflowerblue;
                border-radius: 50%;}
        }

<body>

<div class="nav" ></div>

<body>

效果图:

案列2:

.nav1{
            width: 800px;
            height: 500px;
            border: 1px solid;
            margin: 0 auto;
        }
        .nav2{
            width:100px;
            height:100px;
            background:red;
            position:relative;/*生成相对定位的元素,相对于其正常位置进行定位。*/
            -webkit-animation: yi2  infinite 10s alternate;
        }
        @keyframes yi2{
            0%{
                background: yellow;
                left:0px; top:0px;
            }
            25%{
                background: bisque;
                border-radius: 50%;
                left:700px;
                top: 0;
            }
            50%{
                background: cyan;
                border-radius:50% ;
                top: 400px;
                left: 700px;
            }
            75%{
                background: coral;
                border-radius: 0%;
                top: 400px;
                left: 0px;
            }
            100%{
                background: wheat;
                border-radius: 0;
                left: 0;
                top: 0;
            }
    
        }

<body>

<div class="nav1" >
            <div class="nav2"></div>
        </div>

</body>

效果图:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值