【问题标题】:CSS3 animation weird movement in tablet/mobile平板电脑/手机中的 CSS3 动画奇怪的动作
【发布时间】:2015-12-30 21:01:38
【问题描述】:

我已经为我正在处理的演示项目构建了一些带有关键帧的 CSS 动画。我只是在使用 fadeIn、fadeOut、slideInLeft 和 slideOutLeft,它们在桌面模式下都按预期工作。

但是当我谈到平板电脑/移动版本时,slideInLeft 动画在动画结束时会出现意想不到的动作。类似于缩放效果的东西。我一直在用这个拉头发一段时间。预期的移动是一条从右到左的水平直线。

我的演示项目位于this address。在您单击第一个按钮并且第二页滑入之后,该错误就出现了。如果您刷新页面,动画将按预期运行。

编辑

我的动画:

@keyframes slideInLeft {
    0% { left: 130%; }

    100% { left: 30%; }
}

@-webkit-keyframes slideInLeft {
    0% { left: 130%; }

    100% { left: 30%; }
}



@media (min-width: 768px) {
    @keyframes slideInLeft {
        0% { left: 130%; }

        100% { left: 0; }
    }

    @-webkit-keyframes slideInLeft {
        0% { left: 130%; }

        100% { left: 0; }
    }
}

@media (min-width: 992px) {
    @keyframes slideInLeft {
        0% { left: 130%; }

        100% { left: 10%; }
    }

    @-webkit-keyframes slideInLeft {
        0% { left: 130%; }

        100% { left: 10%; }
    }
}

@media (min-width: 1200px) {
    @keyframes slideInLeft {
        0% { left: 130%; }

        100% { left: 30%; }
    }

    @-webkit-keyframes slideInLeft {
        0% { left: 130%; }

        100% { left: 30%; }
    }
}

.slideInLeft {
    position: absolute !important;
    -webkit-animation: slideInLeft 2s;
    -moz-animation: slideInLeft 2s;
    -ms-animation: slideInLeft 2s;
    -o-animation: slideInLeft 2s;
    animation: slideInLeft 2s;
}

动画元素

.container {
position: absolute;
top: 100%;
left: 30%;
/*transform: translateX(-100%);*/
-webkit-transform: translateY(-60%);
-moz-transform: translateY(-60%);
-ms-transform: translateY(-60%);
-o-transform: translateY(-60%);
transform: translateY(-60%);
width: 40%;
display: block;
text-align: center;
margin: 0 auto;
}

HTML 结构

<div id="container" class="container slideInLeft">
    <div>
        <h1>
            Deactivation
        </h1>
    </div>
    <div>
        <p>
            Enter your activated phone number in international format (e.g. +467012345678)
        </p>
    </div>
    <div class="input-container">
        <input type="text" id="msisdn" />
    </div>
    <div id="loader" class="la-ball-scale-ripple-multiple la-2x spinner">
        <div></div>
        <div></div>
        <div></div>
    </div>
    <div class="dots has-input">
        <ul id="bullet-list">
            <li class="blank"></li>
            <li class="selected"></li>
            <li class="blank"></li>
            <li class="blank"></li>
        </ul>
    </div>
    <div class="button-container">
        <a href="#" class="button inactive" id="send-button">DEACTIVATE NUMBER</a>
    </div>

</div>

任何帮助表示赞赏!

【问题讨论】:

  • 是的,如果您可以发布代码的相关部分,将会很有帮助。谢谢。

标签: html css css-animations


【解决方案1】:

似乎在常规 css 和动画类中使容器“相对”会为你完成这项工作:)

祝你好运!

【讨论】:

    猜你喜欢
    • 2013-02-24
    • 2016-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-14
    • 1970-01-01
    • 2018-05-10
    相关资源
    最近更新 更多