• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Relative and Absolute Positioning

Chapter 9. Relative and Absolute Positioning

The normal way a document is laid out is that the boxes for all elements are put one after the other or below the other (depending on whether they are inline or block), with their distances and alignments specified by properties such as margin, padding, and width. An occasional box is shifted to one side with the float property. In this way, the boxes fill the canvas, or the pages, starting from the top and continuing until all boxes are placed.

Relative positioning adds to this the ability to make corrections to the positions of individual boxes without affecting other boxes. For example, a box may be moved up or down to overlap another box. It is seldom needed in a style sheet. The place where the properties for relative positioning usually appear is in scripts. For example, a dynamic effect that cannot be achieved with CSS2 (although maybe with a future level of CSS) is to move text into place on opening a document: The text moves in from the side and the headers fall into place from the top, slowly reducing their relative offsets to zero. Scripts aren’t very good at creating smooth motion effects, but so far, there is no other solution that works with HTML.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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