Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS removing white space in a specific situation

Take a look at this.

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. This results in white space being added to #window-frame. I do not want this. I want no gap between "TOO" and "NEXT ITEM". Can this be done using CSS? I'd rather not fool with heights using JS. Also, any insight as to why this is happening?

Thanks

like image 509
Booker Avatar asked Feb 22 '23 17:02

Booker


2 Answers

Try using margin-top instead of animating the top property:

$('#latest-image-list').animate({marginTop: "-=20"}, "fast");

Here is a demo: 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). Always use var to make sure you aren't creating global variables unnecessarily (which creates extra overhead each time the variable is looked-up).

like image 136
Jasper Avatar answered Feb 24 '23 08:02

Jasper


If the list must be relatively positioned, animate marginTop instead of top.

JSFiddle

like image 23
Wes Pearce Avatar answered Feb 24 '23 08:02

Wes Pearce