开发者社区> 问答> 正文

使用:after和animation制作的遮罩层出现的问题?

想做一个当网页打开时.d1有个淡出效果动画,但是d1始终是空白?

<div class="d1"></div>

    .d1{
        width: 20px;
        height: 20px;
        background-color: red;
        position: relative;
    }
    .d1:after{
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        background-color: #fff;
        z-index: 1;
        -webkit-animation: d1_mask 5s linear 0 forwards;
        animation: d1_mask 5s linear 0 forwards;
    }
    @keyframes d1_mask{
        0%{opacity: 1}
        100%{opacity: 0}
    }

展开
收起
杨冬芳 2016-06-21 18:20:20 1793 0
1 条回答
写回答
取消 提交回答
  • IT从业

    animation: d1_mask 5s linear forwards;这样,forward不要跟count同时使用

    2019-07-17 19:45:11
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载