我试图让一个 div 从页面顶部扩展到底部。当动画开始时,div 将被隐藏(高度为 0%),直到它以 100% 填充页面。我试过这样做,但似乎都不起作用:
HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>About Me</title>
<link rel="stylesheet" href="stylesheets/main.css">
</head>
<body>
<div id="bar"></div>
</body>
</html>
CSS:
*
{
box-sizing: border-box;
}
body
{
height: auto;
width: auto;
direction: ltr;
z-index: 1;
background-color: #fff;
}
#bar
{
position: relative;
top: 0px;
left: 0px;
width: 5%;
background-color: #3b5598;
display: block;
-webkit-animation: bar 7s ease;
}
@keyframes bar
{
0% {
top: 0%;
}
100% {
top: 100%;;
}
}
我以前有过从左到右的动画,但没有从上到下的动画。我已经广泛地用谷歌搜索了这个但无济于事。谢谢
最佳答案
您可以尝试以下操作:
.container{
background:lightblue;
height:1000px;
-webkit-animation: expand 5s;
}
@-webkit-keyframes expand{
0%{height:0px}
100%{height:1000px}
}
关于html - 使用 CSS3 动画将 div 从屏幕顶部移动到底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19145952/