This is a discussion on "Vertically centering Div's" within the Web Page Design section. This forum, and the thread "Vertically centering Div's are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Vertically centering Div's
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Vertically centering Div's
I was working on creating a vertically centered div. I did find a way however which sadly only works in IE. Dose anybody know how to vertically center a div which in most browsers?
Heres the code for IE DIV Centering:
|
|
|
|
||||
|
Re: Vertically centering Div's
The traditional method of handling IE6 and Firefox/others was something like:
body: {text-align: center; margin: 0 auto;} div.wrap {margins: [whatever] auto; text-align: left;} setting the parent div/element to left/right margin "auto" centers it in most browsers. For IE < 7, you have to center the text in a parent, then align it back to left in the target div. Also, at the top of your css, the following code prevents problems:
Last edited by masonbarge; Mar 17th, 2007 at 10:28. |
|
||||
|
Re: Vertically centering Div's
Mason seems to have misunderstood the question. That's for horizontal centering. And he should've clarified. The * { margin: 0; padding: 0; } won't prevent problems, it will simply remove all margin and padding from every element on the page. This is sometimes helpful because different browsers have different default margin and padding settings. It is by no means necessary, however.
verkevinmanering69err455: The code you posted is rather poor. Something like the following would work and validate.
|
|
||||
|
Re: Vertically centering Div's
http://www.newguyinennis.com/samples...centering.html
http://www.newguyinennis.com/samples...ing_fluid.html
Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
|
![]() |
| Tags |
| centering, div tag, vertical |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Centering Vertically | R8515198 | Web Page Design | 5 | Dec 6th, 2007 11:05 |
| [SOLVED] Centering horizontally and vertically | Emzi | Web Page Design | 4 | Nov 1st, 2007 16:07 |
| Div's tags in IE = death | verkevinmanering69err455 | Website Planning | 2 | Mar 12th, 2007 04:43 |
| Div's overlapping | fluerasa | Web Page Design | 2 | Oct 8th, 2006 10:09 |
| centering vertically | benbacardi | Web Page Design | 17 | May 27th, 2004 13:51 |