[英]CSS removing white space in a specific situation
Take a look at this. 看看这个。
http://jsfiddle.net/DTxQf/18/ http://jsfiddle.net/DTxQf/18/
When you click on the body of the lower right box, "TOO" is appended to the ul and animated upwards. 当您单击右下方框的主体时,“TOO”将附加到ul并向上动画。 This results in white space being added to #window-frame.
这导致向#window-frame添加空白区域。 I do not want this.
我不想要这个。 I want no gap between "TOO" and "NEXT ITEM".
我希望“TOO”和“NEXT ITEM”之间没有差距。 Can this be done using CSS?
可以使用CSS完成吗? I'd rather not fool with heights using JS.
我宁愿不用使用JS的高度傻瓜。 Also, any insight as to why this is happening?
此外,任何有关为什么会发生这种情况的见解?
Thanks 谢谢
Try using margin-top
instead of animating the top
property: 尝试使用
margin-top
而不是使用top
属性设置动画:
$('#latest-image-list').animate({marginTop: "-=20"}, "fast");
Here is a demo: http://jsfiddle.net/DTxQf/27/ 这是一个演示: http : //jsfiddle.net/DTxQf/27/
Also, on a side-note, you created the height
variable without the var
statement which put it in the global scope (otherwise it would have been inside the window.load
event handler scope). 另外,在旁注中,您创建了
height
变量而没有将其置于全局范围内的var
语句(否则它将位于window.load
事件处理程序范围内)。 Always use var
to make sure you aren't creating global variables unnecessarily (which creates extra overhead each time the variable is looked-up). 始终使用
var
来确保不会不必要地创建全局变量(每次查找变量时会产生额外的开销)。
This should explain: http://jsfiddle.net/DTxQf/32/ 这应该解释: http : //jsfiddle.net/DTxQf/32/
Where is MOO
? MOO
在哪里? Not visible (under the top fold), but still there. 不可见(在顶部折叠下),但仍然存在。
Despite translating the list up by 20px, it still takes the same space. 尽管将列表翻译了20px,但它仍然需要相同的空间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.