 |
 |
Can't get top margin to go away (HTML/CSS)
|
 |
|
 |
|
Clinically Insane
Join Date: Dec 1999
Status:
Offline
|
|
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
|
|
Originally Posted by olePigeon
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
|
|
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
|
|
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
|
|
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
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |