Old 03-24-2006   #1 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

css margin problem

hi, I have a small problem with css margins. I have the following html document (simplified for testing purposes)

Code:
        <h1 id="contop">start</h1>
	<div class="conbg">
		<div class="conbg2">
			<h1>topic</h1>
			<div class="tiny">24.3.2006</div>
			<p>test text...</p>
		</div>
	</div>
	<h1 id="conbottom">end</h1>
css is the following:

Code:
h1#contop {
	background-image: url('images/contop.jpg');
	background-repeat: no-repeat;
	width: 525px;
	height: 39px;
	text-indent: -9999px;
	margin: 0px;
}

h1#conbottom {
	background-image: url('images/conbottom.jpg');
	background-repeat: no-repeat;
	width: 525px;
	height: 79px;
	text-indent: -9999px;
	margin: 0px;
}

div.conbg {
	background-image: url('images/conbg.jpg');
	background-repeat: repeat-y;
}

div.conbg2 {
	background-image: url('images/conbg2.jpg');
	background-repeat: no-repeat;
	padding: 0px 40px 0px 40px;
	margin: 0px;
}
And as you can see. If I use margin inside the .conbg2 element it will place the margin between the conbg2 and conbg elements. What am I missing here. I could forget margins and use just paddings but I would like to solve this before I will go there. Any ideas?
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-24-2006   #2 (permalink)
Recursively call who?
 
GoldNetX's Avatar
 
Join Date: Nov 2003
Location: Pittsburgh, PA
Posts: 294

Send a message via AIM to GoldNetX
I am not sure , but I believe the margin is applied to the parent object, and since you have conbg2 nested inside of conbg the margin should occur between the edge of conbg2 and conbg.

I would highly recommend though that you set the 'position:' attribute for each css chunk. It will help by declaring to what orginal object your left, top, and I believe margins are supposed to be based upon.
__________________

www.gusmayo.com
- Maybe a story or two -


www.jaloobie.com
... your new home ...

www.webinkproductions.com
- professional web application design -
GoldNetX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-26-2006   #3 (permalink)
Registered User
 
Dumb Genius's Avatar
 
Join Date: Feb 2005
Posts: 20

It's totally normal.
Look at this W3C image showing how a block element is made:
__________________
Dumb Genius is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-27-2006   #4 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

I still don't get it why it acts like that. Element 1 inside element 2 which is inside element 3. The way I understand it the element 1 margin should go between elements 1 and 2. not between elements 2 and 3. But I "fixed" the problem by placing just something before and after page content though I don't feel happy about my "solution".

But basicly I would like to hear real solution to the "problem" instead of explanations of the problem itself.
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 03-28-2006   #5 (permalink)
Registered User
 
Dumb Genius's Avatar
 
Join Date: Feb 2005
Posts: 20

I think it behaves badly because you didnt set a width in px for div.conbg and div.conbg2.
__________________
Dumb Genius is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XHTML Coding problem bana HTML / PHP / ASP / JS 6 12-21-2005 12:24 AM
sound card problem? scrowler General Discussions 4 12-12-2005 08:09 PM
PHP problem - please help ibanez270dx HTML / PHP / ASP / JS 12 08-31-2005 01:24 PM
Chicken & The Egg Problem! Man1c M0g HTML / PHP / ASP / JS 3 04-05-2005 07:02 PM
redhat problem Milkdrop General Discussions 3 12-14-2003 07:05 AM


All times are GMT +1. The time now is 12:04 PM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2007 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT