Yes, it would be great that we can move from a static position to an absolute one, but really I donβt think it will be soon (if ever). I would be happy to be able to switch from height: px to height: auto; .
My guess is that there is some kind of compromise when the browser has to make a calculation to interpolate between two "incompatible" values. So, if you set height: 20px and then want to switch to height: auto , then the browser will have to imagine what will happen if it has the auto position, and the calculations can become intense. It is also not implemented in jQuery, so I assume it breaks some tests or just hacks.
If you archive your css, knowing that you need an absolute position to always refer to the window, then javascript becomes simpler: you just need to switch between its offset and 0, 0.
$(".hover").on("mouseover", function(){ $(this).css({ top: $(this).offset().top * -1, left: $(this).offset().left * -1 }) });
http://jsfiddle.net/crUFY/
A more robust solution is to clone the dom element and hide the original, and then animate the clone at the top of the window. Thus, you can apply the position: relative to the parent elements.
source share