是错误还是jquery bug?
所以我们有这样的代码例如,在第三次点击图层不再改为底部 ..
<style type="text/css">
#menu1 {
width:100%;
height:32px;
overflow:hidden;
background:#ff0033;
position:fixed;
left:0px;
cursor:pointer;
bottom:174px;
}
#content1 {
position:fixed;
width:100%;
left:0;
overflow:auto;
background:blue;
height:200px;
bottom:300px;
}
</style>
Run Code Online (Sandbox Code Playgroud)
<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
<script type="text/javascript">
$(function(){
var click1=0;
$("#menu1").click(function () {
if (click1==0) {
$("#content1").css({ bottom: "250px", display: "block", position: "fixed" });
click1 = 1;
} else {
$("#content1").css({ top: "100px", "display": "block", display: "block", position: "fixed" });
click1 = 0;
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
如果你有两个top并且bottom设置你有问题,他们要么都应用(并计算高度),或者如果设置了高度,则只top应用.所以你需要擦除你不使用的那些:
{ bottom: 250, top: 'auto' }
{ top: 100, bottom: 'auto' }
Run Code Online (Sandbox Code Playgroud)