嗨,大家好我已经基于jquery在我的网站上实现了一个movile固定菜单,但我在每个句子里面有一个marginTop和marginBottom的问题,marginBottom不工作它的接缝就像缺少的东西,plz检查出来
现场示例: http://www.utxj.edu.mx/menu_example/index.html
我的代码......
$(document).ready(function(){
$(function() {
var d=300;
$('#navigation a').each(function(){
$(this).stop().animate({
'marginTop':'-80px'
},d+=150);
});
$('#navigation > li').hover(function () {
$('a',$(this)).stop().animate({
'marginTop':'-2px'
},200);
}, function () {
$('a',$(this)).stop().animate({
'marginTop':'-80px'
},200);
}
);
});
});
$(document).ready(function(){
$(function() {
var d=300;
$('#navigation2 a').each(function(){
$(this).stop().animate({
'marginBottom':'-80px'
},d+=150);
});
$('#navigation2 > li').hover(function () {
$('a',$(this)).stop().animate({
'marginBottom':'-2px'
},200);
}, function () {
$('a',$(this)).stop().animate({
'marginBottom':'-80px'
},200);
}
);
});
});
Tnx 4帮助。
答案 0 :(得分:1)
利润正在做他们应该做的事情。元素将增长以适应动画块的新大小,其余元素将随之拖动。
作为解决方案,请尝试将元素relative
放置到当前位置,并为top
和bottom
属性设置动画:
li {
position: relative;
}