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

Fixed Positioning

Sometimes, it is desirable to keep an element onscreen at all times. For example, a short warning or a logo could be kept in the corner of the window at all times, no matter how the user scrolls the document. Similarly, when a document is printed, such an element may be printed in a fixed position on every page.

The containing block for a fixed element is thus always the viewport (i.e.,, the browser’s window) or the page box (see Chapter 12, “Printing and other media”). The positioning properties set the distance between the edges of the containing block and the element. If the element is not an image or other “replaced element,” you typically set the width property, and either the left or right property, and of course, top or bottom. The height can usually be left unspecified (auto). For replaced elements, you don’t have to set the width unless you want to scale the image. Setting both left and right, and leaving width as auto is also possible: The width will then be calculated as the width of the viewport minus the left and right values.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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