Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Art & Graphic Design > Can't get top margin to go away (HTML/CSS)

Can't get top margin to go away (HTML/CSS)
Thread Tools
Clinically Insane
Join Date: Dec 1999
Status: Offline
Reply With Quote
Feb 7, 2011, 08:10 PM
 
ClickWidget: Welcome

Could someone take a look at my code? I'm very new to CSS and I can't figure out why the top margin is still there. I thought I set everything correctly.

I would like the background image to be flush with the top of the browser window.
"…I contend that we are both atheists. I just believe in one fewer god than
you do. When you understand why you dismiss all the other possible gods,
you will understand why I dismiss yours." - Stephen F. Roberts
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Feb 7, 2011, 08:12 PM
 
Originally Posted by olePigeon View Post
ClickWidget: Welcome

Could someone take a look at my code? I'm very new to CSS and I can't figure out why the top margin is still there. I thought I set everything correctly.

I would like the background image to be flush with the top of the browser window.

You need to set the margin and padding of the html tag to 0, or else use a CSS reset library. Your body tag doesn't start at the top of the page like you want. You can see this for yourself using the Webkit inspector.
     
Moderator
Join Date: Jun 2000
Location: We come from the land of the ice and snow...
Status: Offline
Reply With Quote
Feb 7, 2011, 08:53 PM
 
You can also set div#main to something like:

margin: 0 auto;
padding: 20px 0 0 0;

and that also takes care of it. Even if I add margin: 0 and padding: 0 to html as Besson suggests, that gap was still there.

There's also a trick with height:100% that you can check out.

There's more than one way to get it done, but I'd recommend putting the stripey pattern as a repeat-y for #main, and putting the other face/deco stuff as the background-position: top for #content. It will help your height issue. I don't think you need position: relative for this layout.
(Last edited by andi*pandi; Feb 7, 2011 at 09:03 PM. )
     
Clinically Insane
Join Date: Dec 1999
Status: Offline
Reply With Quote
Feb 7, 2011, 10:00 PM
 
Thanks for the tips, I'll try them out.

I'm going to change the face. Someone told me it looked like Elvis, and now that's all I see. It was originally a statue from some office building that I used as a template. I think I'll get rid of the hair bun.
"…I contend that we are both atheists. I just believe in one fewer god than
you do. When you understand why you dismiss all the other possible gods,
you will understand why I dismiss yours." - Stephen F. Roberts
     
Clinically Insane
Join Date: Dec 1999
Status: Offline
Reply With Quote
Feb 7, 2011, 10:47 PM
 
I started to reconstruct the HTML/CSS from the beginning, stepping through to see what was happening. Turns out it was my <p> tag. I moved the text-indent from the #content to the P tag, and added the margin properties. That seems to have fixed it.

p {
text-indent: 20pt;
margin: 0;
padding: 0;
}
"…I contend that we are both atheists. I just believe in one fewer god than
you do. When you understand why you dismiss all the other possible gods,
you will understand why I dismiss yours." - Stephen F. Roberts
     
   
Thread Tools
Forum Links
Forum 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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:00 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2