[英]Velocity.js Opacity Is Not Working Properly
I am having problems with animations using velocity.js. 我在使用Velocity.js进行动画时遇到问题。
Here is a Codepen link. 这是Codepen链接。
PROBLEM: 问题:
After the navigation element fades in, the logo and "MY WEBSITE" title momentarily fades out and fades in again. 导航元素淡入后,徽标和“我的网站”标题会暂时淡出并再次淡入。
CODE: 码:
HTML: HTML:
<div id="header">
<div id="logo">
<img src="Images/logo.png" />
</div>
<h1 id="logo-title">MY WEBSITE</h1>
<div id="nav-bar">
<ul>
<li><a href="">HOME</a></li>
<li><a href="">ABOUT US</a></li>
<li><a href="">PROJECTS</a></li>
<li><a href="">CONTACT</a></li>
</ul>
</div>
</div>
CSS: CSS:
*
{
margin: 0;
padding: 0;
font-family: sans-serif;
color: white;
background-color: black;
}
#header
{
width: 100%;
height: 150px;
background-color: black;
}
#logo
{
width: 25%;
height: 100%;
float: left;
opacity: 0;
}
#logo img
{
width: 100%;
height: 100%;
}
#logo-title
{
width: 25%;
float: left;
line-height: 150px;
opacity: 0;
}
#nav-bar
{
width: 100%;
height: 150px;
opacity: 0;
}
#nav-bar ul
{
list-style-type: none;
overflow: hidden;
}
#nav-bar li
{
float: left;
width: 25%;
height: 150px;
}
#nav-bar li a
{
display: block;
text-align: center;
text-decoration: none;
line-height: 150px;
}
#nav-bar a:hover
{
background-color: #333;
}
JavaScript (Velocity.js): JavaScript(Velocity.js):
Velocity(document.getElementById("logo"), {opacity: 1}, {duration: 4000});
Velocity(document.getElementById("logo-title"), {opacity: 1}, {delay: 2000, duration: 4000});
Velocity(document.getElementById("nav-bar"), {opacity: 1}, {delay: 4000, duration: 4000});
I can't seem to find the problem. 我似乎找不到问题。 Any suggestions will be appreciated.
任何建议将不胜感激。 Thanks.
谢谢。
I looked up your pen, and the pen seems to work fine if you just remove float: left
from your logo
and logo-title
class. 我抬起了你的笔,如果只删除
float: left
从logo
和logo-title
类中float: left
,则该笔似乎可以正常工作。 So may be you can remove floats and make div according to that. 因此,可能是您可以删除浮点数并根据其进行div设置。 I am not sure why is this happening.
我不确定为什么会这样。 May be you can raise an issue on github.
也许您可以在github上提出一个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.