cssflexboxcss-grid

Flex layout with two 'modes'


I want to have a layout that adjusts depending on two content profiles. Both have a close button in the upper right corner. The only difference is that the first has a title plus content, while the second only has content (no title).

This is case #1:

enter image description here

In case 2, I want the content section to take over the title area present in case #1.

enter image description here

I haven't done something like this before, and my flex skills haven't seen any action in quite a while, so I'd appreciate some help here.


Solution

  • Just use flex-wrap: wrap on the flex container to force the content to a new line, and make the title and the button fixed width to not leave any space for the content if the title is present.

    https://codepen.io/Lubomyr-Pryt/pen/EaxBGNy