1

我必须在网站的页面加载上显示文本效果,即仅使用没有 jquery 或 java 脚本的 Css 从页面顶部到中间动画 div。我的 div css

#body_welcome_content{ width:450px; margin: 205px auto 0; font-size:48px; font-family: 'Playball', cursive; text-align:center; color:#FFF; margin-top:35px; text-shadow: 0px 1px 0px #000;

}

帮助我成为 CSS 新手。还要确保浏览器间的兼容性,以便它适用于所有浏览器。[没有 jquery] 在此先感谢

4

1 回答 1

2

你可以简单地使用@keyframes

演示

div {
    width: 300px;
    height: 300px;
    background: red;
    animation: centerme 2s;
    -webkit-animation: centerme 2s;
    position: absolute;
    z-index: 999; /* To ensure that box is always on the top */
    animation-fill-mode: forwards; /* So that box doesn't move back to default place*/
    -webkit-animation-fill-mode: forwards;
}

@keyframes centerme {
    0%   {left: 0; top: 0;}
    100%  {left: 50%;top: 50%;margin-top: -150px;margin-left: -150px;}
    /* Left and Top are 50% with margins which are half of width and height */
}

@-webkit-keyframes centerme {
    0%   {left: 0;}
    100%  {left: 50%;margin-left: -150px;}
}
于 2013-06-20T05:16:38.993 回答