Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-04-2009, 02:37 AM   PM User | #1
queirdo
New Coder

 
Join Date: Nov 2008
Posts: 16
Thanks: 1
Thanked 1 Time in 1 Post
queirdo is an unknown quantity at this point
push centered div to top of page?

Here is what I have so far:
http://queirdo.com/index2.htm

I just want to center the #content div and have it at the top of the page. I can center it with margin:0, but then on every browser tested (except IE of course because it always does it's own thing) there is a gap between the div and the top of the page. If I try to absolute position it to top:0px it will no longer be centered.

How can I fix this?

(Why I am using this layout: I have background images that I want to extend on both sides on larger resolutions, but they won't fit on the page with content on 800X600 resolution, so I just want them to disappear when the window is that small. They need to match up exactly with an image I will put in the #content div, so I need it to be in the same place on every browser. I've tried a bunch of other ways to accomplish what I want, but nothing has worked so I'm trying 2 divs underneath the main content to put my background images in, extending from the center.)
queirdo is offline   Reply With Quote
Old 05-04-2009, 02:52 AM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello queirdo,
Try changing
Code:
html, body {
    margin:0;
    padding:0;
}
to this -
Code:
* {
    margin:0;
    padding:0;
}
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
queirdo (05-04-2009)
Old 05-04-2009, 04:27 AM   PM User | #3
queirdo
New Coder

 
Join Date: Nov 2008
Posts: 16
Thanks: 1
Thanked 1 Time in 1 Post
queirdo is an unknown quantity at this point
Yes, that works. It turned out it was the margin or padding on the paragraph inside the div that was shifting things down. Thanks!
queirdo is offline   Reply With Quote
Reply

Bookmarks

Tags
centering, css, div

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:22 PM.


Advertisement
Log in to turn off these ads.