Re: Proposal: easy attribute to uncollapse margins

On Sat, Oct 18, 2014 at 12:36 PM, Jonas Thiem <jonasthiem@googlemail.com> wrote:
> Hi people responsible for CSS,
>
> Sometimes collapsed margins are undesirable on elements with no
> borders and padding, e.g. for the body element if you want to do exact
> height calculations (for example to have its minimum height match the
> viewport height) without the first child or last child's margins
> throwing your calculations off.
>
>
> The internet has come with nightmare'ish hacks to work around this:
>
> http://stackoverflow.com/questions/15007322/clear-fix-and-uncollapse-margins-with-css-without-side-effects
>
> http://stackoverflow.com/questions/6204670/css-clean-solution-to-the-margin-collapse-issue-when-floating-an-element
>
> The shortest and most readable solution I have found is still this
> one: margin: -1px 0 0 0; border-top: 1px solid;
>
>
> However, this is still a hack. The obvious question is: can't you add
> a simple uncollapse-margin:uncollapse; style property or something
> along the lines to the CSS specs?
>
> Sorry if this is already in the specs, but I couldn't find something
> along the lines on the internet and I'm not a regular CSS proposal
> person, so I don't know all of the specs in full detail. Also sorry if
> this mail has gone to the entirely wrong place, this seemed like the
> correct list to mail this to.

You got the right place!

This is a long-standing request, with some standing suggestions on how
to handle it: <https://wiki.csswg.org/ideas/margin-collapsing>.  It
hasn't gone into a spec yet because no one's gotten up the courage to
take over that section of CSS 2.1 and update it in a new spec. ^_^

~TJ

Received on Monday, 20 October 2014 20:55:46 UTC