Jquery Grid Resizer resizes grid columns for even spacing
new GridResizer(containers,childSelector,margin)
containers
is the jQuery object referencing the container element(s) - i.e. the rowchildSelector
is a string selector that finds the column elements within the container element. It is applied usingcontainer.find(childSelector)
so don't include the container in the selectormargin
is the gutter you want between each columnwidthCallback
allows you to do further dom manipulations using the child and container width values
Let's say we have a two containers, one with two columns and another with 5, and we want a gutter of 20px
<div class="gr-container">
<div class="gr-block">1...</div>
<div class="gr-block">2...</div>
</div>
<div class="gr-container">
<div class="gr-block">1...</div>
<div class="gr-block">2...</div>
<div class="gr-block">3...</div>
<div class="gr-block">4...</div>
<div class="gr-block">5...</div>
</div>
new GridResizer($(".gr-container"),".gr-block",20)
This is a very simple script, and I'm mainly putting it up because I've needed to solve this problem a time or two previously and I want to keep a reference to it.
I will consider simple modifications and definitely pull requests, and encourage you to fork and modify this code to meet your needs.