Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


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

8 Dynamic Objects > Plug-in 60: Center (center)

PLUG-IN 60: Center (center)

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.

image

FIGURE 8-4 The example from the previous plug-in is now also centered horizontally.

Variables, Functions, and Properties
image
About the Class

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.

How to Use It

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:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial