Andrey (azangru) wrote,

CSS surprized me today.

Make a container and put some text in it:

then add a negative margin to the heading, so that it become outdented:

no surprises so far:

Now add an overflow-y: auto to the container so that its content could scroll down. The moment you do this, the hanging part of the heading gets cropped by the border of the container:

Overflow-x: visible doesn't help. There must be a spec somewhere that explains why this is the correct behavior; i.e. why overflow-x starts behaving as if it were set to hidden; but it's so unintuitive it's bewildering.

(example in jsfiddle)

Of course the desired effect can still be achieved through a combination of padding and negative margin, but still — yikes!

  • (no subject)

    A Google docs presentation file from a recent event. With a script in the bottom — at least, I assume that this is script; I doubt it's a transcript…

  • (no subject)

    Twitter is an unending fount of amusement today. The creator and former maintainer of Babel is attacking the current maintainer of Babel for slacking…

  • (no subject)

    This is interesting: the quotes from the article, cited in the tweets, are complimentary to the skeptics; the conclusion puts them in the camp of…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.