如何重新计算正确的位置 [英] How to recalculate correct position
问题描述
我认为我在这里被误解了,所以我将重述我的问题.
问题:当我悬停" 在菜单上时,类别为问题" 的黑色跨距跟随我的鼠标,但是它弄乱了它的位置,因为我不知道不知道如何正确计算:(
尝试将鼠标悬停在菜单上以查看问题.
尝试了两天以解决这个问题,但没有成功...
I think I am been misunderstood here so I will rephrase my question.
THE PROBLEM: when I "hover" over the menu the black span with class "problem" follows my mouse but it messes up its position because I don't know to calculate it correctly:(
Try to hover over my menu to see the problem.
Been trying for two days to figure this out, but no success...
这是我网站的 LINK .
有什么帮助或建议吗?
Any help or suggestion?
$(document).ready(function(){
$('.menu ul li').hover(function(){
var index=$(this).index();
var width=$(this).outerWidth();
$('.problem').stop().animate({'marginLeft':135*index+195,'width':width},1000);
});
});
推荐答案
我将首先更新.menu
样式:
float: none;
width: 715px;
height: 30px;
display: block;
position: relative;
margin: 9px auto;
然后,您需要将活动元素移到其后,您可以通过应用负数top-margin
You'll then need to move the active element behind it, which you can possibly do by applying a negative top-margin
这篇关于如何重新计算正确的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!