473,379 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Border/Margin problem

I got a problem with code looking like that:

<div class="outer">
<div class="inner">
Sample text
</div>
</div>

The outer DIV has margin/padding=0, the inner DIV has a margin (all 4
sides). What happens is that the margin does not position the inner DIV
more to the inside of the outer one, but creates a margin between the
outer div and its parent. When a border is added to the outer DIV, it
renders as it (IMHO) should do.

A sample page showing both the problem and the border-workaround, can be
found at http://www.torfbold.com/problem.html

This happens over here on Linux with Mozilla 1.6 and Opera 7.51.

According to my understanding of the CSS Box model
(http://www.w3.org/TR/REC-CSS2/box.html), this is not the correct behaviour.

I would really appreciate it if some could clarify that mystery for me.

Thanks,
Florian
--
Minimum Requirement #3: You know where you want to go tomorrow
(WEB.DE help-wanted ad: Linux Guru)
[------------ http://www.torfbold.com - POV-Ray gallery ------------]
Jul 20 '05 #1
2 2186
In article <2s*************@uni-berlin.de>, to**@torfbold.com says...
I got a problem with code looking like that:

<div class="outer">
<div class="inner">
Sample text
</div>
</div>

The outer DIV has margin/padding=0, the inner DIV has a margin (all 4
sides). What happens is that the margin does not position the inner DIV
more to the inside of the outer one, but creates a margin between the
outer div and its parent. When a border is added to the outer DIV, it
renders as it (IMHO) should do.


Margins collapse. What you see is correct behaviour. See collapsing
margins in CSS spec. Google past posts here if you don't get it from
spec.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 20 '05 #2
> Margins collapse. What you see is correct behaviour. See collapsing
margins in CSS spec. Google past posts here if you don't get it from
spec.


Ooops. Seems I missed that part of the specs. Found it with your help.
Fixed it by using a padding on the outer div.

Thanks for your help!
Florian
--
In mathematics you don't understand things.
You just get used to them. (Johann von Neumann)
[------------ http://www.torfbold.com - POV-Ray gallery ------------]
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Thomas Mlynarczyk | last post by:
Hi, I'm looking for a way to put a 1px solid border around the image in this link: <a href="some.html"><img src="some.gif"></a> Well, that, by itself, is simple. However, I would like to have a...
7
by: CMAR | last post by:
At http://home.ne.rr.com/thespar/designerN.htm on my practice website, I am using the stylesheet "side.css" below. The {body} tag is styled with a solid border of 7.7 em to provide background for...
1
by: Trent L | last post by:
Hello, I'm having a problem where a style for a <a> tag isn't working in IE: border : 1px solid red; If you use my code below, you'll see what I mean. In IE6 on WinXP, I'm not seeing a red...
0
by: smokeyd | last post by:
smokeyd Sep 26, 2:12 pm show options Newsgroups: alt.html From: "smokeyd" <tom_bur...@umbro.co.uk> - Find messages by this author Date: 26 Sep 2005 06:12:11 -0700 Local: Mon, Sep 26 2005...
2
by: tradmusic.com | last post by:
Hi, I'm new to CSS and, following some advice, created my page like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head>...
2
by: jonathandowns | last post by:
i'm trying to put a css border around this box, and it's not working properly in safari and firefox (works fine in IE). can anyone help me fix this? here is a grab so you can see the problem: ...
16
by: FuzzyLogik | last post by:
By width, I don't mean weight. I have a row of <li>'s, with a bottom-border. I want the bottom-border to only go 90% of the <li> (centered) Is there any way to do this? I have it in this...
6
by: Hacking Bear | last post by:
Hi, I still don't quite fully understand how to handle mixing border/margin pixel width with percentage width. In the example below, I want to place side-by-side two DIV boxes inside a box....
0
by: silco | last post by:
Hi Everyone.. hope you can help! I have a IE6 border bug, most of the common fixes tell me to use relative on my container divs. This fixed some problems but now I have a left border problem...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.