Felix2: Hintergrundbild von Elterndiv orientiert sich an Kinddiv

Hallo,

ich habe folgenden Aufbau:

<div id="section">
 <div id="subsection1">bla</div>
 <div id="subsection2">blubb</div>
</div>

Der div "section" hat ein Hintergrundbild, welches im div links oben beginnen soll. Sobald ich nun den div "subsection1" mit einem margin versehe, wird das Hintergrundbild nicht mehr am oberen Rand des Elterndivs positioniert, sondern am oberen Rand von "subsection1".

------------------
|#section        |

--------------
------------------

Kann man das verhindern?

Es grüßt
Felix

  1. Kann man das verhindern?

    Derzeit noch nicht!
    Aber bald!

    mfg Beat

    --
    ><o(((°>           ><o(((°>
       <°)))o><                     ><o(((°>o
    Der Valigator leibt diese Fische
  2. Hi,

    <div id="section">
    <div id="subsection1">bla</div>
    <div id="subsection2">blubb</div>
    </div>

    Der div "section" hat ein Hintergrundbild, welches im div links oben beginnen soll. Sobald ich nun den div "subsection1" mit einem margin versehe, wird das Hintergrundbild nicht mehr am oberen Rand des Elterndivs positioniert, sondern am oberen Rand von "subsection1".

    Nein, das glaubst du nur.

    In Wirklichkeit wird #section um das margin-top, welches du #subsection1 gegeben hast, nach unten verschoben.

    http://www.w3.org/TR/CSS21/box.html#collapsing-margins:
    "The top margin of an in-flow block-level element is adjoining to its first in-flow block-level child's top margin if the element has no top border, no top padding, and the child has no clearance."

    MfG ChrisB

    --
    Light travels faster than sound - that's why most people appear bright until you hear them speak.