Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Plug-in 60 is similar to the middle class, but it centers an object horizontally. In Figure 8-4, the previous example has been extended to also center the inner object using this class.
FIGURE 8-4 The example from the previous plug-in is now also centered horizontally.
By looking up the width of the parent object, this class then sets the marginLeft and marginRight properties of the object to equal values sufficient to display the object exactly in the center.
In order to use this class, the parent object needs to already have a position other than static, such as relative or absolute, and the object to be moved should be given an absolute position, like this: