Absolutely, go ahead and give it a try. To achieve this effect, make sure to utilize only one transform on the element.
One common misconception is that you apply the transform directly to the element itself. In reality, you apply it to the change-state (via a pseudo class like :hover
or another class with the desired styles for the changed state). Take a look at @David's comment on your question for further clarification. Only alter properties that need changing based on the modified state in order to animate them.
To sum up, modify them selectively according to the altered state.
Solution 1: Utilizing Javascript (based on the fiddle link provided in your query)
Check out the demo here: http://jsfiddle.net/abhitalks/6UE28/4/
Relevant CSS Code:
div{
-webkit-transition: all 1s;
-moz-transition: all 1s;
transition: all 1s;
/* Avoid specifying transforms here */
}
Relevant jQuery Code:
$('...').click(function(){
$("#trgt").css({
"-webkit-transform": "scale(0.5)"
});
});
// OR
$('...').click(function(){
$("#trgt").css({
"-webkit-transform": "translate(100px, 100px)"
});
});
// OR
$('...').click(function(){
$("#trgt").css({
"-webkit-transform": "scale(0.5) translate(100px, 100px)"
});
});
Solution 2: Relying solely on CSS
Another demonstration can be found here: http://jsfiddle.net/abhitalks/4pPSw/1/
Relevant CSS Code:
div{
-webkit-transition: all 1s;
-moz-transition: all 1s;
transition: all 1s;
/* Avoid specifying transforms here */
}
div:hover {
-webkit-transform: scale(0.5);
}
/* OR */
div:hover {
-webkit-transform: translate(100px, 100px);
}
/* OR */
div:hover {
-webkit-transform: scale(0.5) translate(100px, 100px);
}