Skip to content

[css-sizing] height: stretch should just behave as height: auto #1614

@tabatkins

Description

@tabatkins

The motivating example for height: stretch's behavior is "what height: 100% should have been" - making the element stretch up to fill its container, even if the container to be filled is further up the ancestor tree (so its direct parent has an indefinite height). However, this ends up with several weird implications:

  • If two descendants both want to be height: stretch, what happens? This'll cause overflow in a confusing manner, I think.
  • If no ancestor is definite-height, it ends up hitting the root, which uses the ICB's height. The screen's height is fairly arbitrary here; it doesn't often actually correspond to what you want an element to do, as in this example

On the other hand, Flex and Grid have useful, reasonable definitions of stretching the height of an element. In the linked example above, for instance, the author could have made the li elements into flexboxes as well; then the a elements would stretch to full height, exactly as desired. (Rather than stretching to the screen's height.)

So it's probably just not worth trying to do height: stretch in some intelligent manner. We should just treat it like 100% minus margins/border/padding, so it only has a useful effect is the immediate parent is definite-height, and otherwise acts like auto.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions