【发布时间】:2015-11-13 21:44:41
【问题描述】:
我正在为客户构建登录页面。他们的徽标以公司标语为中心,正下方,目前标语在页面加载时淡入淡出。
他们现在询问是否可以将标语设置为动画,使其看起来像是在写出来而不是淡入。有没有人知道如何实现这种效果?我被难住了。
任何帮助将不胜感激。
HTML:
<div class="image-wrapper">
<a href="home.html">
<img src="images/landing_logo2.png" />
</a>
<div id="test">
<p>enter the sunshine state</p>
</div>
</div>
CSS:
div.image-wrapper {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}
.image-wrapper img {
display: block;
}
#test {
position: absolute;
top: 100%;
width: 100%;
}
#test p {
width: 100%;
font-family: segoe;
font-size: 18px;
text-align: center;
color: #fff;
margin-top: -40px;
-webkit-animation: fadein 8s; /* Safari, Chrome and Opera > 12.1 */
-moz-animation: fadein 8s; /* Firefox < 16 */
-ms-animation: fadein 8s; /* Internet Explorer */
-o-animation: fadein 8s; /* Opera < 12.1 */
animation: fadein 8s;
}
@keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
}
我附上了一个 JSFiddle:
【问题讨论】:
标签: javascript html css animation centering