• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Relative Positioning

As shown in the last example in the previous section, you can use relative positioning simply to create a containing block for some other absolutely positioned element. However, the typical use of relative positioning is to position elements away from their normal position without influencing the position of other elements. There aren’t many reasons for doing that in a style sheet, and the main reason relative positioning exists at all is to provide a way for scripts to animate the text – to make it “explode” when a page is unloaded or make it slowly move into place when the page is loaded. These effects are well known in slide-show presentations, and with relative positioning and a clever script, you can do the same with HTML.

Unfortunately, scripting languages aren’t good at animation. The way they do it is to enter a loop in which the value of the positioning properties slowly increases or decreases until they reach some preset value. With every change, part of the screen is redrawn. However, even on the fastest computers, the speed at which successive cycles of the loop are executed varies slightly, which causes a jerky motion – enough for the human eye to notice. Real animation programs don’t rely on such loops, but calculate the path of the element in advance, and even create blurry images on purpose, based on the measured speed of the computer, to fool the human eye into believing the object is moving more than it actually is.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint