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

Entomology > Getting Centered

Getting Centered

Centering in CSS is a bit challenging because the legitimate way of centering a design horizontally with CSS doesn’t work consistently across browsers. Hicks ran into this problem while working on Entomology, and he decided to employ a workaround to solve the problem. Before we get to his approach, though, an examination of the various means of centering CSS-based layouts horizontally is in order.

Centered Design Using Auto Margins

The preferred way to horizontally center any element is to use the margin property and set left and right values to auto. For this to work with layouts, you’ll create a containing div. You must include a width for your containing div:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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