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 being applied to previous element.
Old 08-31-2008, 07:09 PM Margin being applied to previous element.
Novice Talker

Posts: 14
Name: Dan
Trades: 0
I have this HTML:

<HTML>
<BODY>

<div id="logo">
<h1><span>Mega Machine Shop</span></h1>
</div>

<div id="call">
<p>Call Us: (360) 555-5555</p>
</div>

</BODY>
</HTML>

and this CSS:

#logo {
float:left;
display:inline;
width:155px;
margin:0;
padding:0;
border: 1px solid yellow;
}

#call {
margin:100px 0 0 0px;
padding:0;
border: 1px solid yellow;
}

For some reason the #logo Div is taking a 100px top margin. Why would this be? What am I not seeing?

Thanks in advance.

-Dan
vapor2020 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-31-2008, 08:32 PM Re: Margin being applied to previous element.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
I'm not entirely sure how to explain why it's happening, but if you add clear: both or clear: left to #call it should look the way you want.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 08-31-2008, 08:55 PM Re: Margin being applied to previous element.
Novice Talker

Posts: 14
Name: Dan
Trades: 0
I don't want #call to clear #logo. I need it to form a second column.
vapor2020 is offline
Reply With Quote
View Public Profile
 
Old 08-31-2008, 08:58 PM Re: Margin being applied to previous element.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Then just remove the 100px top margin on it. The 100px top margin on #call is what's pulling down #logo.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 08-31-2008, 09:00 PM Re: Margin being applied to previous element.
Novice Talker

Posts: 14
Name: Dan
Trades: 0
I know. That's the point. The margin on #call shouldn't be pushing down #logo, should it?
vapor2020 is offline
Reply With Quote
View Public Profile
 
Old 09-01-2008, 12:30 PM Re: Margin being applied to previous element.
LadynRed's Avatar
Defies a Status

Posts: 10,016
Location: Tennessee
Trades: 0
If you don't want the logo to move with the flow, you'll have to float #call too.
__________________
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 09-01-2008, 02:47 PM Re: Margin being applied to previous element.
Novice Talker

Posts: 14
Name: Dan
Trades: 0
I solved my problem, although it still doesn't make any sense. I simply added an element above it within a header div. i.e.:

<body>
<div id="container">
<div id="header">
<div id="menu">
</div>
<div id="logo">
</div
<div id="call"
</div>
</div>
</div>
</body>

And now #logo doesn't move down with #call. I really don't get it, but it works.
vapor2020 is offline
Reply With Quote
View Public Profile
 
Old 09-01-2008, 02:48 PM Re: Margin being applied to previous element.
Novice Talker

Posts: 14
Name: Dan
Trades: 0
Thanks for the help, Vangogh and LadynRed. This site has gotten me out of many a tough spot.
vapor2020 is offline
Reply With Quote
View Public Profile
 
Old 09-01-2008, 11:20 PM Re: Margin being applied to previous element.
vangogh's Avatar
Post Impressionist

Posts: 10,688
Name: Steven Bradley
Location: Boulder, Colorado
Trades: 0
Glad we could help in some way Dan. I would have done the same thing LNR suggestion in floating both divs. I'm still not entirely sure why what you were seeing was happening. I wouldn't have expected it, but at least you found a way to make it work.
__________________
l Search Engine Friendly Web Design |
Please login or register to view this content. Registration is FREE

l Tips On Marketing, SEO, Design, and Development |
Please login or register to view this content. Registration is FREE

l
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Margin being applied to previous element.
 

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.28070 seconds with 12 queries