Although we can achieve fantastic animations through various Javascript libraries such as jQuery. I am wondering what’s the technique behind the animation?
I can think of using CSS to format the page element.
But how can we place an element on arbitrary position of the page? I mean, not by lines. Is it true that we can think of the client area within the browser window as the Paint canvas?
I am totally new to frontend Web development, I hope I made myself clear. And thank you for answering this junior question.
The jQuery way – and the only cross-browser way – to animate is to set some CSS properties, wait a little, update those properties, wait a little, update those properties…
The CSS properties you are interested in are:
position: absolutelets you position the element to an arbitrary location.display: blockordisplay: inline-blocklets an element to have awidthandheighttop,left,bottom,rightdefine the element position if itspositionisabsoluteorrelative.lefttakes precedence overrightandtoptakes precedence overbottom.widthandheightdefine the element’s size.opacitycan be animated to fade an element in or out.padding,border-width,marginand their respective components can all be animated.You can also animate colors:
border-color,color,background.