动画+滤镜

动画

之前使用过渡遇到的一些问题:
1.需要重复过渡效果时无法实现
2.只能通过hover等方式才能出发。

动画:

1.通过**@keyframs定义**动画。

2.在指定元素中,通过animation属性来调用动画。

1.定义动画

格式:

        @keyframes 动画名 {
          
           from{
                    /* 初始帧 */
            }
           to{
                    /* 结束帧 */
            }
    }
    

【注】动画名不要起关键字,最好见名知意。

2.动画的调用

通过animation属性来调用动画。

animation-name

动画名称

animation-duration

执行一次动画的完成时间

animation-iteration-count

动画的执行次数
infinite 表示无数次。

animation-delay

动画延迟执行的时间。

animation-fill-mode
  • forwards:在动画结束后,盒子保持结束帧状态。
  • backwards 在动画开始时,包含延迟时间,让盒子保持初始帧状态
  • both backwards forwards都生效
  • none(默认值)
animation-direction

动画的执行方式

  • alternate:交替执行。
  • normal 正常(默认)
    -reverse 反向 从结束帧开始到初始帧结束。

【注】alternate 反向也会算一次执行时间。

animation-timing-function
  • linear 匀速
  • ease-in 加速
  • ease-out 减速
  • ease-in-out 先加速后减速

【注】动画属性要有中间状态,一般是数值型。

滤镜

透明度

.item:nth-child(1) img{
            /* 透明度 */
            filter: opacity(65%);
        }

灰度

.item:nth-child(2) img{
            /* 灰度 */
            filter: grayscale(60%);
        }

反色

        .item:nth-child(3) img{
            /* 反色 */
            filter: invert(1);
        }

亮度(0-1)

       .item:nth-child(4) img{
            /* 亮度  0-1 */
            filter: brightness(1.6);
        }

饱和度 (0-1)

        .item:nth-child(5) img{
            /* 饱和度  0-1 */
            filter: saturate(30%);
        }

褐色(0-1)

        .item:nth-child(6) img{
            /* 褐色  0-1 */
            filter: sepia(0.6);
        }

模糊(0-1)

        .item:nth-child(7) img{
            /* 模糊  0-1 */
            filter: blur(2px);
        }

色相翻转(deg)

        .item:nth-child(8) img{
            /* 色相翻转  deg */
            filter: hue-rotate(90deg);
        }

对比度(deg)

        .item:nth-child(9) img{
            /* 对比度 */
            filter: contrast(2)
        }

阴影

        .item:nth-child(10) img{
            /* 阴影 */
            filter: drop-shadow(4px 4px 7px #111);
        }

在这里插入图片描述

滤镜阴影与盒子阴影

        .box {
            width: 400px;
            height: 700px;
            position: absolute;
            left: 50%;
            margin-left: -200px;
            top: 50%;
            margin-top: -350px;
        }
        
        .box1,
        .box2 {
            width: 300px;
            height: 200px;
            margin: 50px;
            border: 30px dashed #666;
        }
        
        .box1 {
            /* 盒子阴影 */
            box-shadow: 10px 10px 5px #aaa;
        }
        
        .box2 {
            /* 滤镜阴影 */
            filter: drop-shadow(10px 10px 5px #aaa);
        }
    <div class="box">
        <div class="box1"></div>
        <div class="box2"></div>
    </div>

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值