如果您转到此页面并点击左侧下拉菜单之一 - http://ryancoughlin.com/hp/index.php?c=about - 一旦它到达底部或回到顶部,它几乎看起来像是出现故障/碰撞。
这个问题可以解决吗?或者这就是 jQuery 中的行为方式?
代码:
$(".menu-header").click(function() {
$(this).next().toggle('slow');
return false;
}).next().hide();
最佳答案
在 CSS 中进行更改
#left ul li{
font-size:.7em;
margin:5px 0;
}
至
#left ul li{
font-size:.7em;
padding:2px 0 3px 0;
}
问题是您的边距在动画开始和结束时与 h2
的边距一起折叠,但在动画期间不会折叠,因为 overflow
ul
不可见
*,防止折叠。缺乏折叠会增加 ul
的有效大小。
* W3 on the box model and margin collapsing :
Vertical margins of elements with 'overflow' other than 'visible' do not collapse with their in-flow children.
关于jquery - 奇怪的 jQuery 行为——slide(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/664260/