How to make 1 row with columns that are resizable in width by the users?
Here are some criteria to help you understand what I want.
A layout with 1 row and X number of columns.
The initial width of the columns should be based on its content.
The user should be able to resize the widths of the columns.
All columns have a min-width that should be respected.
I used flexbox for the initial lay-out, then JS to give all cols a width based on whatever flexbox decided.
For the resizing part, I figured that since you're only transferring the width of 2 adjacent cols, you could just calculate the distance the mouse travelled between 2 mousemove events, then swap the cols width based on that value.
This sounded great in my head, but it turned out to be a lot more complicated, especially because the amount of cols needs to be able to change.
I would love to hear other solutions that perhaps use other lay-out tools.
7 Replies
Should I post this question in #back-end ?
I would prefer a CSS solution, but my attempts with the
resize
property didn't get me very far, but I was hoping that somebody else did, or was able to use something else.
Surely this feature is such a common thing that there is something in CSS that enables devs to do it?Backend is definitely not the place for this, it's either CSS or JS in the frontend
though this isn't something you can do with CSS alone, it has to be JS
@Tok124 (CSS Nerd) Fancy seeing you here.
You're such a nerd π π
Hahaha xD
I am everywhere π π
This won't work with multiple columns, they can't all just grow/shrink to fit.
Anybody?