Quantcast

Forums | MacLife

You are not logged in.

#1 2005-12-14 2:01 pm

I'm with stupid
Hey Crabman!
From: Bakersfield, Ca
Registered: 2005-02-01
Posts: 192

css wierdness...

Can someone explain why this is happening.

I have some html:

Code:

<body>
<div id="wrapper">
  <div id="head">
    <h1>Page Heading</h1>
    <form>a search box</form>
  </div>
</div>

and some css:

Code:

body {
    margin: 0;
    padding: 0;
    width: 100%;
    background: white url(images/homepagebackground.png) repeat-x top;
    font-family: Veranda, sans-serif;
    color: #000;
    text-align: center;
    }
#wrapper {
    width: 800px;
    margin: 0 auto;
    background: url(images/topForeBanner.png) no-repeat top;
    text-align: left;
    }

The background image on the body element is a 4x53px image that creates a banner across the top. The image on the wrapper tag is a logo that is 600X53px. It should be placed directly on top of the banner created by the repated image on the body tag, but it adds a top margin so the logo doesn't line up with the banner. I realized that if I add an &nbsp; just after the <div id="wrapper"> in the html it works. The images line up perfectly. Why?

I hope I'm explaining this well enough...


This isn't who it would be if it wasn't who it is.

Offline

 

#2 2005-12-14 2:44 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Not sure why the space would fix it, but my initial thoughts would be to fix the CSS wrongnesses. Correct the font spelling ("Veranda"), and get the background properties in proper shorthand order:

Code:

background: color url("pathname.jpg") horizontal vertical repeat;

You also might try specifying the div's padding as 0. You also shouldn't have to set body to 100%, as that's implied. (I'm also assuming you just left out the closing body tag.)

Try that and see what gives. Also, a link would be nice, so we can see the site and code in their entirety.

Offline

 

#3 2005-12-14 2:45 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Sorry for all the "also"'s. Whew.

Offline

 

#4 2005-12-14 2:50 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

Yeah, a little confusing. smile But I believe it has to do with your H1 tag. The margin on header tags will "jump through" divs. The extra space you're seeing is actually the margin of the header being applied above the div. I'm sure there's logic behind this decision, but I don't know what it is. Anyway, either killing the margin-top on the header or (maybe?) specifying a padding on #wrapper will fix your problems.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#5 2005-12-14 2:56 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

reefdog wrote:

Not sure why the space would fix it, but my initial thoughts would be to fix the CSS wrongnesses. Correct the font spelling ("Veranda"), and get the background properties in proper shorthand order:

Code:

background: color url("pathname.jpg") horizontal vertical repeat;

You also might try specifying the div's padding as 0. You also shouldn't have to set body to 100%, as that's implied. (I'm also assuming you just left out the closing body tag.)

Try that and see what gives. Also, a link would be nice, so we can see the site and code in their entirety.

Actually, the background code he has is valid. Order and/or inclusion of properties is not required for the background tag. At least, according to W3Schools. That was my first thought, too. I'd run it through the validator, but I am way too lazy to write a HTML page, upload it, and then validate it.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#6 2005-12-14 2:58 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Ooh, good call. (On the h1.)

Yesh, the background thing wouldn't account for the bug, but I can't help but recommend cleanup when needed. Improper shorthand will often work, but it's still improper.

Offline

 

#7 2005-12-14 3:07 pm

I'm with stupid
Hey Crabman!
From: Bakersfield, Ca
Registered: 2005-02-01
Posts: 192

Re: css wierdness...

Ah ha!!! padding did it.

I actually tried setting the padding to 0 earlier, because the logo was being pushed down on the page, not up, but that had no effect - (neither did killing the top margin on the h1). I thought there was some extra padding somewhere that was being applied that I needed to remove. I still don't understand why giving it padding works, but it does. Thanks.

CSS Wierdness indeed...


This isn't who it would be if it wasn't who it is.

Offline

 

#8 2005-12-14 3:43 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Margin collapsing. Basseq was right: the h1 (and maybe #head's) margin was peeking through the #wrapper's bounds and pushing #wrapper away from the top of the page. Giving #wrapper vertical padding effectively told all its child elements "your margins can't poke through me anymore."

I wish margin-collapse were definable, just like border-collapse. Will that change in CSS3?

By the way, obviously I'm excellent at explaining why other people are right. Props to Basseq for actually, y'know, resolving the problem.

Offline

 

#9 2005-12-14 6:35 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

And I'm good at figuring out what is wrong, but having no idea why. We make a good team. We should probably go into fighting crime.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#10 2005-12-14 9:41 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Fixxy and Splainer!

Offline

 

#11 2005-12-14 9:57 pm

TonyPrevite
Slobbering Jester
Royal Wombat
From: Glendale, AZ
Registered: 2002-04-14
Posts: 3606
Website

Re: css wierdness...

reefdog wrote:

Ooh, good call. (On the h1.)
Improper shorthand will often work, but it's still improper.

Well, laa tee frikin da!   wink

Offline

 

#12 2005-12-14 10:01 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Hit him, Fixxy. Hit him in the face.

Offline

 

#13 2005-12-14 11:35 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

http://homepage.mac.com/oatmeal/MAF/maxes/troutage2.gif

But I don't know why!


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#14 2005-12-15 2:09 am

TonyPrevite
Slobbering Jester
Royal Wombat
From: Glendale, AZ
Registered: 2002-04-14
Posts: 3606
Website

Re: css wierdness...

drool

Offline

 

#15 2005-12-15 3:32 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

This thread cracks me up every time I read it.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#16 2005-12-15 6:19 pm

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

So, do we get outfits, or what? And where's our lair going to be? I vote for deep in the Aztec ruins. Ice castles and lava caves are soooo done.

TonyPrevite wrote:

drool

That truly is the most versatile maxie ever.

Offline

 

#17 2005-12-15 9:13 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

I'm not really into the spandex thing. I mean, go for it if you like, but give me jeans and a t-shirt any day. Oh, but Aztec ruins are fine with me. Unless you suggest the Azores. I mean, just say it. Azores. It sounds cool. I think they're mountains, and I think cool stuff happens there.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#18 2005-12-16 7:57 am

reefdog
Manly man
Registered: 2000-05-15
Posts: 10701

Re: css wierdness...

Spandex is right out. Jeans are great, and a tee. But if we're going to be in the mountains, we should probably have thick lambswool jackets. And, of course, wide hats to keep off the rain. We'll also want mountain-capable transportation, so... maybe some horses. And a cover job that will let us come and go to our lair without the locals getting suspcious. I know... cowboys! Cowboys who work on a lonely mountain range, secretly sharing a connection that none but they know.





http://www.justinreese.com/media/images/brokeback.jpg

Dammit.

Offline

 

#19 2005-12-16 2:07 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

"Cowboys who work on a lonely mountain range, secretly sharing a connection that none but they know."

Yikes.

OK, so let's refine this. Firstly, we need women. Secondly, we need a dedicated T1 line. I don't think order is important here.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#20 2005-12-16 2:49 pm

Splainer
...of F&S fame!
From: Azores. Er... a secret lair.
Registered: 2005-12-16
Posts: 3

Re: css wierdness...

This seemed necessary, too.

If we're going for a wishlist, let's just make it a DS3 and Scarlett Johansson. And I think it goes without saying that we need elaborate secret passageways, a bronze bust with hidden button, and a butler.


There is no problem so complex that I can't easily describe someone else's solution.

Offline

 

#21 2005-12-16 2:53 pm

Stan
Member
From: Rock Island
Registered: 2002-04-09
Posts: 713

Re: css wierdness...

Are you going to live on Broke Code Mountain?

Offline

 

#22 2005-12-16 2:56 pm

Splainer
...of F&S fame!
From: Azores. Er... a secret lair.
Registered: 2005-12-16
Posts: 3

Re: css wierdness...

These sorts of jokes will not be tolerated. Ring Of Validation, activate!


There is no problem so complex that I can't easily describe someone else's solution.

Offline

 

#23 2005-12-16 4:37 pm

Basseq
Fixxy of F&S fame
From: D.C.
Registered: 2002-12-18
Posts: 3125
Website

Re: css wierdness...

I think you mean "Hit him, Fixxy. Hit him in the face."

To which I would respond: http://homepage.mac.com/oatmeal/MAF/maxes/troutage2.gif

And I am way too lazy to switch back and forth between alts. I thought about it, but then I decided that I'm not that big of a nerd. Thank you, reefy/splainer for stepping up to that particular plate. wink But as for the rest, you have my acknowledgment and acceptance of terms.


Basseq is me, John Whittet.
(Finishing the remainder of the thought expressed in the post has been left as an exercise for the reader.)

Offline

 

#24 2005-12-16 5:32 pm

TonyPrevite
Slobbering Jester
Royal Wombat
From: Glendale, AZ
Registered: 2002-04-14
Posts: 3606
Website

Re: css wierdness...

drool

Offline

 

#25 2005-12-16 5:45 pm

I'm with stupid
Hey Crabman!
From: Bakersfield, Ca
Registered: 2005-02-01
Posts: 192

Re: css wierdness...

Holy Crap!!!! eek

You leave your thread for one minute and look what happens....

It gets overrun by superheros, everytime.

Last edited by I'm with stupid (2005-12-16 5:46 pm)


This isn't who it would be if it wasn't who it is.

Offline

 

Board footer

Powered by PunBB 1.2.6
© Copyright 2002–2005 Rickard Andersson