15.8 Document and Element Geometry and Scrolling
In this chapter so far we have thought about documents as abstract trees of elements and text nodes. But when a browser renders a document within a window, it creates a visual representation of the document in which each element has a position and a size. Often, web applications can treat documents as trees of elements and never have to
15.8 Document and Element Geometry and Scrolling | 389
think about how those elements are rendered onscreen. Sometimes, however, it is necessary to determine the precise geometry of an element. We’ll see in Chapter 16 , for example, that the CSS can be used to specify the position of an element. If you want to use CSS to dynamically position an element (such as a tooltip or callout) next to some ordinary browser-positioned element, you need to be able to determine the location of that element.
This section explains how you can go back and forth between the abstract, tree-based model of a document and the geometrical, coordinate-based view of the document as it is laid out in a browser window. The properties and methods described in this section have been implemented in browsers for a long time (though some were, until recently, IE-specific and some were not implemented by IE until IE9). At the time of this writing, they are going through the W3C standardization process as the CSSOM-View Module (see http://www.w3.org/TR/cssom-view/ ).欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/27722.html