Modal box conflict with css key frames

老子叫甜甜 提交于 2019-12-10 11:42:19

问题


I have created a modal box, and works fine! After, i resolve insert a fadeInUp effect, using css keyframes. But, after make this, the modal box lost the centered position.

Can anyone help me resolve this? Thanks in advance!

Modal box with keyframe conflit DEMO

Original modal box DEMO


回答1:


In your demo you added in a CSS animation which contained this:

keyframes fadeInUp {
     0% {
        opacity: 0;
        -webkit-transform: translateY(20px);
     }
     100% {
        opacity: 1;
        -webkit-transform: translateY(0);
    }
}

This overwrites your translate(-50%, -50%) which is set before the animation runs.

If you change it to:

keyframes fadeInUp {
    0% {
        opacity: 0;
        margin-top: 20px;
    }       100% {
        opacity: 1;
        margin-top: 0;
    }
}

You get the same effect but you don't overwrite your centering offset!

Demo here



来源:https://stackoverflow.com/questions/21418634/modal-box-conflict-with-css-key-frames

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!