Skip to content

A very simple, lightweight, dependency-free height matcher for layouts that don't use grid of flexbox

License

Notifications You must be signed in to change notification settings

jamiemlaw/height-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Height Matcher is a very simple, lightweight, dependency-free library for creating equal-height areas of content, for use in column layouts not using flexbox or CSS grids.

Usage

var elems = document.querySelectorAll('.elem');

matchHeight(elems);

window.addEventListener('resize', function () {
  matchHeight(elems);
});

By default, elements are resized to match height on a row-by-row basis. If you want to force all the elements to have the same height regardless of row, you can pass true as an optional second parameter.

var elems = document.querySelectorAll('.elem');

matchHeight(elems, true);

window.addEventListener('resize', function () {
  matchHeight(elems, true);
});

To stop matching an elements' height, you can use matchHeight.restore:

matchHeight.restore(elems);

Example

https://codepen.io/jamiemlaw/pen/weqoZz

About

A very simple, lightweight, dependency-free height matcher for layouts that don't use grid of flexbox

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published