题目描述
使用jquery的animate,让两个div叠在一起,点击按钮往上跑,可以看到它们的交界处滚动的非常不雅。图片看不出来可以复制代码到本地。。。
题目来源及自己的思路
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
.father{
margin-top: 200px;
margin-bottom: 200px;
}
.son1{
width: 100px;
height: 100px;
background-color: red;
position: relative;
}
.son2{
width: 100px;
height: 100px;
background-color: green;
position: relative;
}
点击
$("button").click(function(){
$(".son1").animate({top:-100},500);
$(".son2").animate({top:-100},500);
})
你期待的结果是什么?实际看到的错误信息又是什么?
如何让这两个div很自然向上滚动呢,解决交界处的问题