Friday, September 3rd, 2010

Creating a centered DIV

Thursday, April 23rd, 2009 by Jonathan Lau

This post briefly show you how to created a DIV which centers itself on the page.
It relies on pure CSS and does not require any JavaScript.

To center it vertically, you would need to set a fixed height for your page.

HTML:

<div id="centered">Your centered DIV</div>

CSS:

#centered{
width:700px;
height:400px;
position:absolute;
top:50%;
left:50%;
margin-left:-350px;
margin-top: -200px;
}

 

Preview

 

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Comments

Receive updates on the comments through RSS 2.0!

6 Responses to “Creating a centered DIV”


  1. August 13th, 2010 at 3:50 am

    Bereken zelf uw hypotheek. Hypotheek berekenen? Maak snel een indicatieve berekening van het maximale leenbedrag van uw hypotheek.


  2. August 15th, 2010 at 1:36 am

    U wilt geld lenen zonder BKR toetsing? De opties hiervoor worden groter, kijk verder en ontdek hoe u wél geld kunt lenen, snel & eenvoudig.


  3. August 22nd, 2010 at 8:06 pm

  4. August 25th, 2010 at 1:01 am

    It sounds like you’re making difficulties yourself by looking for to solve this trouble instead of searching at why their is a dilemma inside Very first place. thanks !!! very really helpful post!


  5. August 26th, 2010 at 1:09 pm

    Great blog 9/10! Bookmarked :)


  6. August 31st, 2010 at 8:02 am

    Aw, this is a good piece. In theory I’d like to write this way too – taking skill and serious focus to produce a fantastic article… nevertheless what can I say… I put things off a lot and by no means manage to get things carried out…

Leave a Reply