Hmmm, I was looking for this problem a bit and I don’t think it is possible with CSS Animations. I try with this JSFiddle several different things and run through tutorials on CSS animations (if someone mentions the same problem), as well as other information about this .
Then I came to the realization of what you are trying to achieve, and I think that perhaps there is an easier solution. If the locations would be dynamically computed, I would suggest that you really use some level of Javascript (or some crazy crazy advanced CSS calc method), so I would at least think that you would set the style of the DOM element with a new left or top . Although I'm not talking about jQuery animations, you can use CSS3 Transitions instead in conjunction with Javascript instead. This means that you get some of the benefits of CSS animation, such as computing, which is more native (hardware acceleration), rather than in Javascript, but you will lose a few things.
Most importantly, there are no transition events for the browser , for example, for CSS animations , and you cannot control small fonts over key frames, but you can work with it dynamically. I suggest this only because your question only relates to a key frame of 0% and one of 100% .
The problem with what you're trying to do is that using CSS animations should be static and will not pull out the values that are currently set for the animation (as opposed to transitions). When you use inherit , you are actually trying to use its top and left , etc. from this parent .
Again, this does not meet your requirement for pure CSS, but using CSS Transitions means only limited manipulation of the DOM through Javascript, not what iQuery aimate does.
Here is another JSFiddle without using jQuery (only very simple javascript to set the class or inline styles) and CSS transitions.
HTML
<div class="myselector-one" id="a">Click Me</div> <div class="myselector-two" id="b">Click Me</div>
Javascript
document.getElementById("a").onclick = function() { if (this.className.indexOf("animate-complete")!=-1) { this.className = this.className.replace(/animate\-complete/g,""); } else { this.className += " animate-complete"; } } var bIsTransitioned = false; document.getElementById("b").onclick = function() { if (!bIsTransitioned) { this.style.top = "50%"; this.style.left = "50%"; this.style.width = "100%"; this.style.height = "60%"; } else { this.style.top = ""; this.style.left = ""; this.style.width = ""; this.style.height = ""; } bIsTransitioned = !bIsTransitioned; }
CSS
.myselector-one { top:10em; left:0em; width:10em; height:5em; transition:all 2s; background-color:#ffaa99; position:absolute; } .myselector-two { top:4em; left:30em; width: 15em; height: 8em; transition:all 2s; background-color:#aaff99; position:absolute; } .animate-complete { top: 50%; left:50%; width: 100%; height: 60%; }