Skip to content

[css-sizing] max-width: 100% while also using width: min-content on container #1927

@o-t-w

Description

@o-t-w

https://www.w3.org/TR/css-sizing-3/#width-height-keywords

Using min-content to get text to wrap to the same size as an image is very helpful.

<div class="container">
<img>
<p> lorem ipsum etc </p>
</div>

However, most users also need to make sure that on small screens/mobile there is no horizontal scrolling, which would normally be achieved with max-width: 100% on images.

.container {
width: min-content;
}

img {
max-width: 100%;
}

These two things do not seem to be compatible with one another. Setting max-width: 100% on the image causes min-content to stop working on the element containing the image.

I realise why this can't work as the logic becomes circular, but is there a solution to constraining image widths on smaller screens?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions