Flexbox Dynamic Line Separator

Nice one by Ahmad Shadeed: a line-separator between two flex items that plays nice with either flex-directions. The line itself is dynamically injected using generated content. As it becomes part of the flexbox layout it’s contained in — something I didn’t know — you can control its flex properties. The trick is to: Stretch the …


This content originally appeared on Bram.us and was authored by Bramus!

Nice one by Ahmad Shadeed: a line-separator between two flex items that plays nice with either flex-directions.

The line itself is dynamically injected using generated content. As it becomes part of the flexbox layout it’s contained in — something I didn’t know — you can control its flex properties.

The trick is to:

  1. Stretch the injected line
  2. Manually set the order of the line (or items) so that the line sits in between them items.

Here’s a demo:

See the Pen
Flexbox Dynamic Line Separator
by Ahmad Shadeed (@shadeed)
on CodePen.

Try resizing the embed above to see the .section‘s flex-direction alter between row and column. The separator will be correctly positioned, thanks to flexbox’s nature.

Flexbox Dynamic Line Separator →


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2022-03-06T07:56:31+00:00) Flexbox Dynamic Line Separator. Retrieved from https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/

MLA
" » Flexbox Dynamic Line Separator." Bramus! | Sciencx - Sunday March 6, 2022, https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/
HARVARD
Bramus! | Sciencx Sunday March 6, 2022 » Flexbox Dynamic Line Separator., viewed ,<https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/>
VANCOUVER
Bramus! | Sciencx - » Flexbox Dynamic Line Separator. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/
CHICAGO
" » Flexbox Dynamic Line Separator." Bramus! | Sciencx - Accessed . https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/
IEEE
" » Flexbox Dynamic Line Separator." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/. [Accessed: ]
rf:citation
» Flexbox Dynamic Line Separator | Bramus! | Sciencx | https://www.scien.cx/2022/03/06/flexbox-dynamic-line-separator-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.