为什么用transform: translateY无效果,而用top却有效果

来源:2-14 编程练习

烟宇

2017-10-12 22:31:12

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>2-4</title>

    <style type="text/css">

        div {

            font-family: 'Microsoft Yahei';

            font-size: 60px;

            font-weight: bold;

            line-height: 600px;

            position: absolute;

            top: -1000px;

            right: 0;

            left: 0;

            width: 800px;

            height: 600px;

            margin: auto;

            text-align: center;

            border: 5px solid #000;

            border-radius: 50%;

            animation-name: disp;

            animation-duration: 1s;

            /*此处写代码*/

            -webkit-animation-delay: 2s;

            animation-delay: 2s;

           

       }

        @keyframes disp {

            from {

                transform: translateY(-1000px);

            }

            to {

                transform: translateY(90px);

            }

        }

   </style>

</head>

<body>

    <div>大家好,欢迎来到慕课网!</div>

</body>

</html>


写回答

1回答

好帮手慕糖

2017-10-13

你好,因为div的样式中使用的是top哟,若想动画中使用 transform: translateY(-1000px);建议:把 div的样式中也改为:transform: translateY(-1000px);

祝学习愉快~

0

0 学习 · 5760 问题

查看课程

相似问题