Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Margin for h2 moves its containing div
Old 05-11-2009, 06:24 PM Margin for h2 moves its containing div
Experienced Talker

Posts: 48
Name: April
Trades: 0
I have no idea why, but when I tell my h2 (which is now an image thanks to css) to have a top margin, it ALSO moves down the element that it is contained in: my "white div" (therefore there is an odd patch of green- a background element-between my nice white div and my button menu) Any imput would be helpful. I can't seem to think of anything else to try. To my knowledge everything should be working correctly, but there must be a mistake somewhere.

I couldn't find any "inherited misbehaviors"....so here is the code that applies. I'll post more if we still can't figure this out.

<div id="white">
<h2>Our Mission</h2>
<div id="p1">
<p>Paragraph1</p>
</div>
<div id="p2">
<p>Paragraph2</p>
</div>
<div id="p3">
<p>Paragraph3</p>
</div>
<div id="serviceicons">
<h3>Services</h3>
<dl>
<dt><a href="#">Icon</a></dt>
<dd>Writing Services</dd>
<dt><a href="#">Icon</a></dt>
<dd>Website Solutions</dd>
<dt><a href="#">Icon</a></dt>
<dd>Graphic Design</dd>
<dt><a href="#">Icon</a></dt>
<dd>Photography</dd>
</dl>
</div>
</div>

and here is the css:
#white{
width: 600px;
height: 775px;
padding-top: 0px;
margin-top: 0px;
margin-bottom:0px;
margin-right: auto;
margin-left: auto;
background-color: #fff;
border-right-style: solid;
border-right-color: #fff;
border-right-width: 1px;
border-left-style: solid;
border-left-color: #fff;
border-left-width: 1px;
}
#white h2 {
width: 164px;
height: 48px;
margin: 0;
text-indent: -5000px;
padding-left: 10px;
background: url(images/mission.png) no-repeat;
}

Ironically the paragraphs and other elements in "white div" act perfectly normal. I cannot figure out what is going on with my h2! Thank you for taking a look.
mightyjoeape is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-11-2009, 08:20 PM Re: Margin for h2 moves its containing div
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
It's caused by margin collapse and it is NOT a bug. Add padding-top: 1px to your #white div and the problem will go away.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 05-11-2009, 08:39 PM Re: Margin for h2 moves its containing div
Experienced Talker

Posts: 48
Name: April
Trades: 0
Thank you, I wouldn't have thought of that.
mightyjoeape is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 10:22 AM Re: Margin for h2 moves its containing div
Novice Talker

Posts: 8
Trades: 0
I think LadynRed's handle should be LadyNerd. I mean that as a compliment, you're so sharp on these things.
Nobunaga is offline
Reply With Quote
View Public Profile
 
Old 05-12-2009, 10:28 AM Re: Margin for h2 moves its containing div
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
LOL.. thank you I am a self-confessed GEEK, no offense taken. However, I have been doing this stuff for a LOT of years!
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Margin for h2 moves its containing div
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36629 seconds with 12 queries