场景: 获得UL的名单内2个链接,李:我的信息并登录 一个环节必须表现出箱(带淡入动画)与链路上使用HOVER里面的时候的一种形式。 当您在链接上进行HOVER时,其他链接会在框中显示一个按钮(使用淡入动画)。简单的jQuery fadeIn fadeOut动画 - 如何显示/隐藏DIVS?
表格必须淡出形式的链接“LOG IN”或鼠标移开时用户鼠标移开。 带有按钮的方框,当用户MOUSEOUT的链接“我的信息”或鼠标悬停时,必须淡出。
问题(两者相同): 形式在前看不见当鼠标移开链接MY INFO。 当MOUSEOUT链接登录时,div内的按钮消失。
注: 1 /形式必须是可见当鼠标按键被链接或在FORM 2 /与按钮框必须是可见的WHEN鼠标位于链接或与按钮
引用盒: 查看屏幕最顶部的www.conforama.fr,链接是带有图标的“Compte”,它有一个类:“with-hover-menu”。当您将鼠标悬停时,表单将出现。当您将链接或窗体鼠标移出时,表单将消失。我需要相同的,但与淡入。眼下
你可以看看下面的代码在此的jsfiddle:http://jsfiddle.net/75HYL/19/,但它不工作的。我不知道如何做到这一点。想了解和学习...!
<ul class="links">
<li class="classA"><a><span>My info</span></a></li>
<li class="classB"><a><span>Log in</span></a></li>
</ul>
<div id="userInfo">USER MUST BE ABLE TO CLICK THE BUTTON BELOW, SO THIS BOX MUST STAY VISIBLE<br/>
<input type ="button" value="OKAY"/>
<div id="login" >
<div class="form">
<form>
<input type="textfield" value="enter your email"></input>
<input type="checkbox"><option>remember me? </option><input>
<input type="button" value="Click me"/>
</form>
</div>
</div>
</div>
<style>
.links li { display:inline-block;cursor:pointer; }
.links li { padding:0 4px 0 1px; }
.links li.classA {width:147px; height:77px;background:url(../images/sprites01.png) no-repeat -226px 0px;}
.links li.classB {width:147px; height:77px;background:url(../images/sprites01.png) no-repeat -226px 0px;}
.links li.classA span {}
.links li.classB span {}
.links li.classA:hover {background:url(../images/sprites01.png) no-repeat -226px -80px;}
.links li.classB:hover {background:url(../images/sprites01.png) no-repeat -226px -80px;}
.links li.classA a {color:#fff;text-transform:uppercase;background:#00aaff;padding:5px 5px 0 20px;margin:5px 0 0;font-size:1em;height:50px;display:block;}
.links li.classB a {color:#00aaff;text-transform:uppercase;background:orange;padding:5px 5px 0 20px;margin:5px 0 0;font-size:1em;height:50px;display:block;}
#login {display:none;width:250px;height:250px; background:#bbb;color:#000;border:1px solid red;}
#userInfo{display:none;width:250px;height:250px; background:#bbb;color:#000;border:1px solid red;}
</style>
<script>
$("li.classA").hover(function() {
$("#userInfo").fadeIn('fast').css('display', 'block');
});
$("#login, .classA").mouseleave(function() {
$("#userInfo").fadeOut('fast').css('display', 'none');
});
$("li.classB").hover(function() {
$("#login").fadeIn('fast').css('display', 'block');
});
$("#login, .classA").mouseleave(function() {
$("#login").fadeOut('fast').css('display', 'none');
});
</script>
非常感谢我从来没有想过100毫秒的技巧,即它几乎是它,但在您的脚本中,如果用户离开链接“登录”或“我的信息”,该框保持可见。例如,在“我的信息”框中显示鼠标,然后将鼠标移至右侧,框仍然存在。它应该fadeOut,就像鼠标离开盒子时一样。 – mlclm
http://jsfiddle.net/WcUFe/2/ mouseLeave事件被附加到错误的元素:)他们应该被附加到李元素,并容器... :)我复制/粘贴和附加两次到容器,并且一次到LI .. – Quamis
这似乎做了窍门。谢谢!将查找和研究你的代码。感谢您的帮助:) – mlclm