style-elements icon indicating copy to clipboard operation
style-elements copied to clipboard

`width content` doesn't size based on actual content width

Open JBetz opened this issue 8 years ago • 2 comments

I'm trying to use width content to automatically size elements, but it isn't working as expected. No matter what type of layout I use, the element always takes up 100% of the space available to it. This even happens when all of its child elements have widths with a specific length.

Example: https://ellie-app.com/6s4qgHd5Ga1/0

Versions

  • Elm: 0.18
  • style-elements: 4.1.0
  • Browser: Chrome + Firefox

JBetz avatar Oct 16 '17 04:10 JBetz

It works if you first wrap the column in a row

main : Html msg
main =
    Element.layout stylesheet <|
        row None
            []
            [ column Card
                [ width content, padding 10, spacing 5 ]
                [ h1 Heading [] (bold "Title")
                , row None [ spacing 5 ] [ bold "notes", text "something something" ]
                , row None [ spacing 5 ] [ bold "date", text "10/6/2017" ]
                ]
            ]

cgudrian avatar Nov 04 '17 21:11 cgudrian

@cgudrian That is a good workaround, although I think the true issue remains. In your example, you can remove width content and it doesn't change the result, so it's redundant here.

The real issue seems to be that width content merely sets width: auto; in the css rather than width: fit-content; which is what I would expect it to do. If you inspect the css for the element in question and set it manually, it will do as expected (in Chrome at least).

@mdgriffith any insights into this issue?

colinhunt avatar Feb 20 '18 05:02 colinhunt