Positioning last div at end, when using flex and flex-wrap
Hi!
See screenshot for reference.
I'm banging my head against this one. I have a flex container with flex-wrap enabled. I want the last button (class "close-button") to show at the bottom right corner of the flex-container. The number of buttons in the container can be anything.
I also want the container height to only be the needed height. So if there are only 3 room buttons, it should only be high enough to show the three buttons plus the close buttons.
I can't get this to work without setting the container to a fixed height.
Any input is appreciated.
Thanks in advance.
PS. This is my first post, so please let me know if this should be structured in better way
Simplified fiddle:
https://shorturl.at/buyA3
6 Replies
Wow!
This was quite a thinker! 😂
First, here's the code to fix it:
I want to try and give an explanation, but only if you actually need it
Thanks @EIO!
But then we will always be at max height, so if we only have 3 buttons, the height would still be max-height.
That's where the max height you set comes into play.
And that's how the height of the div is controlled.
The problem is I want it to be responsive based on the content. That's why I'm using max-height. As it is now I could just omit max-height and set height to
calc(100vh - 16rem)
Oh, I see your point.
But even with a single column, you would still need a fixed height to get the space between the regular buttons and the close button
I think I was a little vague in my initial description. I only want the space between when it is "needed". When there is only one column, no space will be needed.