我有一个网页,其中jquery的animate()函数在IE和FF中完美运行,但它在Chrome中异常工作
这是我的COde
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
html{
width:100%;
height:100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
ul, ol, dl {
padding: 0;
margin: 0;
}
.clearFloat{
clear:both;
height:0;
font-size: 1px;
line-height: 0px;
}
#navigation{
width:100px;
height:100%;
position:fixed;
z-index:1;
left:0px;
position:relative;
}
#navigation .title-list{
width:450px;
position:relative;
left:-350px;
height:100px;
}
#navigation .title{
width:90px;
height:30px;
background-color:#f5f5f2;
position:absolute;
right:-90px;
top:35px;
}
#navigation .image{
width:100px;
height:100px;
float:right;
background-color:#e5e5e4;
}
#navigation .image_hover{
width:100px;
height:100px;
float:right;
background-color:#e5e5e4;
display:none;
}
#navigation .title-list:hover .image{
display:none;
}
#navigation .title-list:hover .image_hover{
display:block;
}
#navigation .sub-menu{
width:350px;
height:30px;
float:right;
background-color:#f5f5f2;
margin-top:35px;
position:relative;
}
#navigation .title-list .drop-sub{
display:none;
}
#navigation .title-list:hover .drop-sub{
display:block;
position:absolute;
z-index:2;
width:225px;
right:20px;
background-color:#CC3;
padding-top:70px;
}
#navigation .sub-list{
width:205px;
padding:10px;
height:30px;
background-color:#e5e5e4;
}
#navigation a{
display:inline-block;
width:100%;
height:100%;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
$('#navigation .expand').hover(function(){
$(this).stop().animate({'left':'0px'},'fast');
}, function(e) {
$(this).stop().animate({'left':'-350px'},'fast');
});
});
</script>
</head>
<body>
<div id="navigation">
<ul>
<li class="title-list expand"><div class="title">About</div><img src="images/navigation/about.png" class="image" /><img src="images/navigation/about_hover.png" class="image_hover" />
<div class="sub-menu">
<div class="drop-sub">
<div class="sub-list"><a href="#">College</a></div>
<div class="sub-list"><a href="#">History</a></div>
<div class="sub-list"><a href="#">Principal's Message</a></div>
<div class="sub-list"><a href="#">Contact</a></div>
<div class="sub-list"><a href="#">Gallery</a></div>
</div>
</div>
</li>
<li class="title-list expand"><div class="title">Academics</div><img src="images/navigation/academics.png" class="image" /><img src="images/navigation/academics_hover.png" class="image_hover" />
<div class="sub-menu">
<div class="drop-sub">
<div class="sub-list"><a href="#">Subjects</a></div>
<div class="sub-list"><a href="#">Structure</a></div>
</div>
</div>
</li>
</ul>
</div>
</body>
</html>
当我在FF或IE中运行此代码并将鼠标悬停在菜单项上时,菜单项会按预期向右移动
当我在chrome中运行此代码并将鼠标悬停在其中一个菜单项上时,菜单首先向左移动一点,然后向右移动到其预期位置
有人有解决方案吗?
编辑:------------------
发生了这种情况,因为缩放设置为镀铬的110%。 然而,任何人都有解决方案,可以做些什么来避免这种情况?
答案 0 :(得分:1)
这是因为在Chrome页面加载时,Chrome中的定位设置为自动。
如果你首先在jQuery中将 left 设置为页面加载时应该是什么,那么你应该没问题。