search

Home  >  Q&A  >  body text

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

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

<p class="d1"></p>

    .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}
    }
PHP中文网PHP中文网2876 days ago616

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 11:37:25

    animation: d1_mask 5s linear forwards;In this way, do not use forward and count at the same time

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:37:25

    @keyframes also needs compatibility processing and vendor prefix; pay attention to the documentation!

    reply
    0
  • Cancelreply