Hello,
The following gives different results in IE and "Non-IE" browsers:
<div style="backgrou nd-color: green; width: 200px">
<div style="margin-top: 20px; background-color: red">
Hello
</div>
</div>
While IE shows a visible green top margin of 20px, Mozilla and other
browsers start the parent element's background color only at the height of
the inner div, thus showing no green at all. Is there a way to achieve the
same behaviour (one way or the other) in all browsers?
Greetings,
Thomas 19 4903
in comp.infosystem s. www.authoring.stylesheets, Thomas Mlynarczyk wrote: Hello,
The following gives different results in IE and "Non-IE" browsers:
<div style="backgrou nd-color: green; width: 200px"> <div style="margin-top: 20px; background-color: red"> Hello </div> </div>
While IE shows a visible green top margin of 20px, Mozilla and other browsers start the parent element's background color only at the height of the inner div, thus showing no green at all. Is there a way to achieve the same behaviour (one way or the other) in all browsers?
Collapsing margins here. Use padding on outer element.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Also sprach Lauri Raittila: While IE shows a visible green top margin of 20px, Mozilla and other browsers start the parent element's background color only at the height of the inner div, thus showing no green at all. Is there a way to achieve the same behaviour (one way or the other) in all browsers?
Collapsing margins here. Use padding on outer element.
Unfortunately, this wouldn't "work" in my case. There are several equally
styled inner elements, vertically separated by a top margin. Using a top
padding on the outer element would mean that the margin no longer collapses
and I would end up with more vertical space than I want. I suppose I could
give the first element a special treatment but I find it not very elegant to
introduce a class="first" for that. (I know there are special CSS selectors
for such a purpose, but IE doesn't support them.) I think that if I put a
border on the outer element, the margin would no longer collapse, but what
if I don't want a border?
Or is there a way to make IE collapse the margin as well?
in comp.infosystem s. www.authoring.stylesheets, Thomas Mlynarczyk wrote: Also sprach Lauri Raittila:
Collapsing margins here. Use padding on outer element.
Unfortunately, this wouldn't "work" in my case. There are several equally styled inner elements, vertically separated by a top margin. Using a top padding on the outer element would mean that the margin no longer collapses and I would end up with more vertical space than I want.
Only use bottom margin on inner elements? (margin: 0 20px 20px 20px;)
Use padding on inner element? someting like padding-top:1px;
(Or do some tricks with relative positioning.)
I suppose I could give the first element a special treatment but I find it not very elegant to introduce a class="first" for that.
div.outer:first-child {margin-top:0;}
(I know there are special CSS selectors for such a purpose, but IE doesn't support them.)
But you didn't have problem with IE, right?
I think that if I put a border on the outer element, the margin would no longer collapse, but what if I don't want a border?
Yes, any content, border or padding between margins means that margin
won't collapse
Or is there a way to make IE collapse the margin as well?
Make sure it is in standards mode. Don't know if it helps though.
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Also sprach Lauri Raittila: Only use bottom margin on inner elements? (margin: 0 20px 20px 20px;)
That would only move the problem from top to bottom :-( And my experiments
have shown that it creates other problems with IE.
Use padding on inner element? someting like padding-top:1px;
Yes, but I'd like to have padding, border and margin of all elements
"available" for design styling. If I used padding to replace margin, I
couldn't use borders, as they would appear in the wrong place.
(Or do some tricks with relative positioning.)
Ah, I hadn't thought of that - this might be a good idea indeed! :-)
div.outer:first-child {margin-top:0;}
(I know there are special CSS selectors for such a purpose, but IE doesn't support them.)
But you didn't have problem with IE, right?
I wanted to achieve the same behaviour in "all" browsers, be it IE's way or
the other. But your suggestion with the first-child selector opens up new
roads for me to explore, so to speak :-) Thanks! I think that if I put a border on the outer element, the margin would no longer collapse, but what if I don't want a border?
Yes, any content, border or padding between margins means that margin won't collapse
So, theoretically,
..outer:before {
content: ".";
height: 0;
display: block;
visibility: hidden;
}
might do the trick, assuming that hidden stuff still "counts" as content. I
must try that out...
Come to think of it, does the margin actually *collapse* here? I mean, the
space defined by that margin is still there, only non-IE browsers seem to
"move" it outside the parent element, while IE keeps it within. The visual
difference is just the background covering the margin space in IE but not in
other browsers. Or is there a way to make IE collapse the margin as well? Make sure it is in standards mode. Don't know if it helps though.
It is. It doesn't :-(
in comp.infosystem s. www.authoring.stylesheets, Thomas Mlynarczyk wrote: Also sprach Lauri Raittila:
Only use bottom margin on inner elements? (margin: 0 20px 20px 20px;) That would only move the problem from top to bottom :-( And my experiments have shown that it creates other problems with IE.
Maybe your it would not fall apart, if you had 1px padding on top and
bottom of outer div? IMHO that is better than playing with relative
positioning or negative margins...
I don't think many could see the difference... (Or do some tricks with relative positioning.)
Ah, I hadn't thought of that - this might be a good idea indeed! :-)
div.outer:first-child {margin-top:0;}
(I know there are special CSS selectors for such a purpose, but IE doesn't support them.)
But you didn't have problem with IE, right?
I wanted to achieve the same behaviour in "all" browsers, be it IE's way or the other.
If it would work on IE, do you need to know it is because 2 bugs happen
to have opposite effect? After all, next IE version either fixes both
bugs, or you can ignore it... Yes, any content, border or padding between margins means that margin won't collapse
So, theoretically,
.outer:before { content: "."; height: 0; display: block; visibility: hidden; }
might do the trick, assuming that hidden stuff still "counts" as content. I must try that out...
Should work (on Gecko and Opera), but I don't think it is good idea.
There is at least 3 better ways...
Come to think of it, does the margin actually *collapse* here?
Yes.
I mean, the space defined by that margin is still there,
Margin of outer and inner div collapse to single margin.
only non-IE browsers seem to "move" it outside the parent element, while IE keeps it within.
It just looks like that, as outer div does have 0 margin. Give it 50px
margin, and you see it makes no difference what margin the inner div
has...
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Also sprach Lauri Raittila: Maybe your it would not fall apart, if you had 1px padding on top and bottom of outer div? IMHO that is better than playing with relative positioning or negative margins... I don't think many could see the difference...
Indeed, that would be the simplest solution.
Margin of outer and inner div collapse to single margin.
only non-IE browsers seem to "move" it outside the parent element, while IE keeps it within.
It just looks like that, as outer div does have 0 margin. Give it 50px margin, and you see it makes no difference what margin the inner div has...
So the browser looks for the bigger of the two margins and uses only that?
While I agree that there are many circumstances, where this behaviour
simplifies things, there are also many instances (like this one) where the
collapsing is bad. Isn't there a way to explicitly tell the browser what one
needs? A "margin-collapse" attribute?
in comp.infosystem s. www.authoring.stylesheets, Thomas Mlynarczyk wrote: Also sprach Lauri Raittila:
Maybe your it would not fall apart, if you had 1px padding on top and bottom of outer div? IMHO that is better than playing with relative positioning or negative margins... I don't think many could see the difference... Indeed, that would be the simplest solution.
Margin of outer and inner div collapse to single margin.
only non-IE browsers seem to "move" it outside the parent element, while IE keeps it within.
It just looks like that, as outer div does have 0 margin. Give it 50px margin, and you see it makes no difference what margin the inner div has...
So the browser looks for the bigger of the two margins and uses only that?
Yes.
While I agree that there are many circumstances, where this behaviour simplifies things,
Practically always, exept in this situation... It is so natural that even
if hardly anyone knows anything about margin collapsing, they expect it
happen.
there are also many instances (like this one) where the collapsing is bad.
Can you name one other? And after that, a solution that would solve the
problem...
Isn't there a way to explicitly tell the browser what one needs? A "margin-collapse" attribute?
No. But you could use float:left;widt h:100%; as margins for floats do not
collapse...
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Also sprach Lauri Raittila:
[Collapsing margins simplify things] Practically always, exept in this situation... It is so natural that even if hardly anyone knows anything about margin collapsing, they expect it happen.
Yes, but not when an element inside a container suddenly has its margin
sticking out of the latter. Of course, theoretically the top margin of the
inner element could always be replaced by by a top padding of the outer
element. In that case, however, the inner margin does not collapse with the
outer padding, and if there are several equally styled inner elements (<li>
inside <ul>, for example), one must explicitly set the first <li>'s top
margin to zero. And again, we face the problem of browser support for the
first-child selector :-( there are also many instances (like this one) where the collapsing is bad.
Can you name one other?
You mean, unlucky me stumbled over the only case where the collapsing is a
problem?
And after that, a solution that would solve the problem...
If I had one, I wouldn't have started this thread...
Isn't there a way to explicitly tell the browser what one needs? A "margin-collapse" attribute?
No. But you could use float:left;widt h:100%; as margins for floats do not collapse...
Interesting. I must try that. But I'm afraid this will trigger a lot of
other problems. Thanks for this hint, though!
in comp.infosystem s. www.authoring.stylesheets, Thomas Mlynarczyk wrote: Also sprach Lauri Raittila:
there are also many instances (like this one) where the collapsing is bad. Can you name one other?
You mean, unlucky me stumbled over the only case where the collapsing is a problem?
Well, I have not seen any other, nor can I imagine one. There is not many
features that are better designed in CSS... And after that, a solution that would solve the problem...
If I had one, I wouldn't have started this thread...
Meaned, how would you change CSS spec, so that it would solve the problem Isn't there a way to explicitly tell the browser what one needs? A "margin-collapse" attribute?
No. But you could use float:left;widt h:100%; as margins for floats do not collapse...
Interesting. I must try that. But I'm afraid this will trigger a lot of other problems.
It does. Box modell makes it sure difficult, if you have some borders or
paddings... I still wonder why they didn't include box-sizing to CSS2.1 -
after all, almost every browser already supported it...
--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Oscar |
last post by:
Hi to everyone!!!!
I have a problem. I need to call to a function of a child (set in an
iframe) from the parent.
Is it posible? I tried to do this with objects such as textbox
(changing its content) and there were no problems.
What can i do?
|
by: Earl Teigrob |
last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at
http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx
but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution.
...
|
by: JohnR |
last post by:
Let's say I have an MDI parent form with a textbox. If I create an MDI
child form and, at runtime, move the MDI child window over the textbox on
the MDI parent, the textbox appears in front of the MDI child window.
How can I make the MDI child window appear in front of any controls that may
be on the MDI parent?
thanks, John
|
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.
1. Each box takes up 50% of the parent.
2. One of the box has a border width of 1px.
|
by: wlevins |
last post by:
I have a simple script which has worked flawlessly for years - it copies a bit of data from a child window down into a form field in the parent window that opened the child.
But now in Firefox 2.0 it does not work.
Parent window: user clicks on button or link to open a child window.
Child Window: child opens and shows a browse file field. Upon submit, child window refreshes and actually loads a second .asp page in the child. This...
| |
by: gregbacchus |
last post by:
I am trying to make an animated Expander, that slides open and
closed.
It works fine, however when in put another Expander inside it, the
triggers/routed events seem to get a little confused. When the child
Expander is closed, it runs the CollapseMe Storyboard on the parent
(even if the child doesn't have the Animated Template). Of course I
don't want this to happen, because it's just weird.
Can anyone help me please :)
|
by: Summercool |
last post by:
I just found that for a table, the margin for <trand <tdare not
honored, but the padding is... is this a widely known fact? why make
this an exception for margin, i wonder.
margin not honored:
http://www.0011.com/test_table/index-margin.html
padding honored:
http://www.0011.com/test_table
|
by: GTalbot |
last post by:
Hello fellow authoring.stylesheets colleagues,
Can someone please explain why the bottom margin of the last inflow
block-level child in an overflowed parent should not have its margin
reachable. I read and re-read carefully the CSS 2.1 spec and I just
can not see why.
Related webpages:
http://www.gtalbot.org/BrowserBugsSection/MSIE8Bugs/MarginBottomChildNotRendered.html
|
by: Paradox4 |
last post by:
Hi,
I'm converting an existing Perl script from UNIX to Windows XP.
This script calls another Perl script in the background using backticks and ampersand (`x_child.pl ... &`).
The child script acts as a timeout check for the parent and will kill it if it's stuck for too long.
Eventually, the parent will also kill the child script - using the shell's `ps -ef | grep x_child.pl ...` to locate the child's PID.
I need to replicate...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |