JQuery 帮助悬停/淡入淡出/动画图像
我想创建一个 javascript/jquery,以便当我悬停一个
我尝试使用熔岩灯效果,但是停止移动功能看起来很奇怪,但这就是我能想到/实现的全部。然而,后来我遇到了另一个问题,我希望“悬停”图像淡入和淡出。
你可以看看这个菜单,它是我迄今为止所实现的 - http://valkesh.000space.com
基本上代码如下-
I would like to create a javascript/jquery so that when I hover an
I tried using the lavalamp effect, however it looks weird stopping the movement functionality, but thats all I could think of/achieve. However then I came across another problem, one that I would like the 'hover' image to fadeIn and fadeOut.
You could take a look at this menu, its what I achieved so far - http://valkesh.000space.com
Basically the code is the following-
<style type="text/css">
ul.nav { list-style:none; overflow:hidden; }
ul.nav li { float:left; height:39px; background-color:#666666; padding:0 5px; }
ul.nav li.last { -moz-border-radius-topright:9px; -webkit-border-top-right-radius:9px;
-moz-border-radius-bottomright:9px; -webkit-border-bottom-right-radius:9px;
}
ul.nav li.bg { margin:7px 0px 0px 3px; padding-right:8px; position:absolute; z-index:50; left:155px; width:60px; background:url(bg-right.png) no-repeat right top; }
ul.nav li .left{ background:url(bg.png) no-repeat left top; height:39px; }
ul.nav li a {padding:8px 20px; color:#000000; font-size:18px; font-weight:bold; display:block; text-decoration:none; z-index:100; position:relative; }
</style>
<script type="text/javascript" src="jquery-1.3.1.min.js"></script>
<script src="jquery.easing.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#nav1 li.bg').css({opacity: 0, visibility: "visible"});
$('#nav1 li a').hover(function()
{
var offset=$(this).offset();
var thiswidth =$(this).width()+13;
$('#nav1 li.bg').stop().animate({left:offset.left+"px",width:thiswidth+"px"},100);
$('#nav1 li.bg').css({opacity: 0, visibility: "visible"}).animate({opacity: 100});
},
function()
{
$('#nav1 li.bg').stop().animate({left:"155px",width:"60px"},100);
$('#nav1 li.bg').css({opacity: 0, visibility: "visible"});
});
});
</script>
<body>
<div class="menucontainer" style="margin-top:15px;">
<ul class="nav" id="nav1">
<li><a href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact Us</a></li>
<li class="bg"><div class="left"></div></li>
</ul>
</div>
</body>
I would appreciate if anyone can guide me into at least doing the hover with 2 or 3 images
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试一下这段代码,因为我想我可以用它来做你想要的事情。我拉出了淡入和淡出动画,并将它们放入单独的悬停中(对于
)。我没有接触 CSS 或 HTML。
Try this code out as I think I got it to do what you wanted. I pulled out your fadeIn and fadeOut animations and put them into a separate hover (for the
<ul>
). I didn't touch the CSS or the HTML.