You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to center an element that has some size constraints. The element should be as large as it can, with a maximum width of X pixels (300 in the Ellie demo). This allows it to shrink on small screens, or when there are lots of neighbors, but be big otherwise.
What I did
https://ellie-app.com/4hVvVyzgVa1/0
The Ellie uses a green background to make it easy to tell where the el is.
In short: el Background [center, width fill, maxWidth (px 300)]
What I Expected To Happen
I expected the el (the green block) to be centered and 300 pixels wide, shrinking when you shrink the screen.
What Actually Happened
The el is left-aligned and 300 pixels wide, and does properly shrink when the screen is shrunk.
If width fill is omitted or changed to width content, then the el is centered properly. To be clear, I am not talking about the text being centered within the green block, I am talking about the green block being centered on the screen. Because I am talking about the centering of the el itself, and not of the text within the el, I believe that this is a separate thing from what Richard is talking about in #101.
width (fillPortion 1) has the same behavior as width fill.
I speculate that the maxWidth attribute is not necessary for the center attribute to be stomped by the width fill, but it is only when all three are present that you can tell that this has happened.
Versions
Elm: 0.18
style-elements: 4.2.1
Browser: Safari Version 11.0.1 (12604.3.5.1.1)
Operating System: macOS 10.12.6
The text was updated successfully, but these errors were encountered:
If I understand the code correctly, this is because content is set to Length Auto, which is translated to width: auto.
A future solution would be to map it to width: fit-content, which is currently experimental. In the meantime, a workaround would be to use vendor-attributes.
The big picture of what I'm trying to do
I am trying to center an element that has some size constraints. The element should be as large as it can, with a maximum width of X pixels (300 in the Ellie demo). This allows it to shrink on small screens, or when there are lots of neighbors, but be big otherwise.
What I did
https://ellie-app.com/4hVvVyzgVa1/0
The Ellie uses a green background to make it easy to tell where the
el
is.In short:
el Background [center, width fill, maxWidth (px 300)]
What I Expected To Happen
I expected the
el
(the green block) to be centered and 300 pixels wide, shrinking when you shrink the screen.What Actually Happened
The
el
is left-aligned and 300 pixels wide, and does properly shrink when the screen is shrunk.If
width fill
is omitted or changed towidth content
, then theel
is centered properly. To be clear, I am not talking about the text being centered within the green block, I am talking about the green block being centered on the screen. Because I am talking about the centering of theel
itself, and not of the text within theel
, I believe that this is a separate thing from what Richard is talking about in #101.width (fillPortion 1)
has the same behavior aswidth fill
.I speculate that the
maxWidth
attribute is not necessary for thecenter
attribute to be stomped by thewidth fill
, but it is only when all three are present that you can tell that this has happened.Versions
The text was updated successfully, but these errors were encountered: