Matchbox

A vanilla JavaScript plugin for... well... matching the height of boxes.

It's still not easy to make boxes in a row the same height with CSS alone when they have dynamic inner contents, they can't be a fixed height, and they need to be responsive.

Matchbox is a vanilla JavaScript plugin to help you do this. It does the work of matching each box to the tallest in its row, listens and responds to the resize event to keep your boxes the same height when inner content shifts around, and can be customized on the fly.

Let's look at a common example. Three boxes in a row, each with differently heighted inner content.

100px
150px
125px

Matchbox is designed to match heights in groups of boxes, thus, each row of boxes will be adjusted separately.

100px
150px
125px
180px
140px
160px

Now, let's see it work with some actual content. Let's do a typical use case scenario. You have to display a set of items, each item with a photo and a small bit of text to go along with it. Let's add the challenge of changing how many items are in a row at different breakpoints.

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab aut consequatur nesciunt, minima dolore quae similique est vero ad cum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eveniet repudiandae nostrum rerum consectetur, accusantium quaerat et optio suscipit! Sint quos illum ad in aliquam voluptatibus cum asperiores eos necessitatibus ab, tenetur, animi praesentium culpa numquam dolore voluptate, incidunt. Eum, illo?
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ex ea non incidunt.
Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab aut consequatur nesciunt, minima dolore quae similique est vero ad cum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Molestiae voluptatem, dolores laborum non unde, iure maxime magnam autem delectus repellendus.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur nihil officiis voluptas blanditiis esse, amet eaque animi aliquid alias quod maxime asperiores sit, laborum voluptatibus aut pariatur. Praesentium consectetur, porro consequuntur dolorum quo facere earum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Temporibus voluptatibus hic saepe dolores earum. Architecto, dolore soluta cum.
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Temporibus voluptatibus hic saepe dolores earum. Architecto, dolore soluta cum.