Topic: Vertically centered box......help !!!! (Page 1 of 1) |
|
---|---|
Nervous Wreck (II) Inmate From: |
posted 04-09-2004 16:16
I'm sorry, but I'm a CSS Newbie...and I have a problem. |
Nervous Wreck (II) Inmate From: |
posted 04-09-2004 16:29
sorry, here's the CSS code : |
Maniac (V) Inmate From: Seoul, Korea |
posted 04-09-2004 16:40
OK, first off, you have two "margin-top" declarations--the "margin-top:50px;" is extraneous, and gets overridden by the next declaration anyway. However, that's not your problem. The technique is sound and should work--in fact, it does work. Your problem is most likely that the height of the div is 700px, and even on a 1024x768 screen, that's going to end up being more vertical space than you have in the browser window. |
Maniac (V) Inmate From: Cell 666 |
posted 04-09-2004 16:43
Your code is pretty messy, so try this: code: body {
|
Maniac (V) Mad Scientist From: :morF |
posted 04-10-2004 07:50
Or, to make this layout type liquid, don't declare anything in terms of pixels. This is good for layout with absolute positioning that are only expected to work on one resolution, but it simply doesn't cut it elsewhere. Try declaring the width and height of your box as 50%, then having a margin-top of 25% and a margin-left of 25%. This puts the left hand side of your box a quarter of the browser window out, and so puts the center of your box exactly at the center of the browser window. The same thing goes for the top. This will then stretch vertically if the text overflows it, but still maintaining its position in the exact center of the window, no matter its size. |