-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated demo and readme instructions
- Loading branch information
Showing
7 changed files
with
163 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,126 @@ | ||
# equalizer.js | ||
A JavaScript plugin for equalizing the height of elements | ||
A vanilla JavaScript plugin for equalizing the height of elements. No jQuery required, but if you're using jQuery that's just fine. | ||
|
||
## Installation | ||
Insert the script into your HTML and initialize Equalizer. Initialization should be done using the load event for best results. | ||
|
||
|
||
``` | ||
<script src="equalizer.min.js"></script> | ||
<script> | ||
window.addEventListener('load', function() { | ||
Equalizer.init(); | ||
}); | ||
</script> | ||
``` | ||
|
||
You may want to use your own breakpoints for your project. To do so, pass those values in the settings object when you initialize Equalizer. Breakpoints are calculated in a mobile first format, so you don't need to include a breakpoint for `0px`. | ||
|
||
``` | ||
Equalizer.init({ | ||
breakpoints: { | ||
small: 480, | ||
medium: 640, | ||
large: 1024, | ||
xlarge: 1200 | ||
} | ||
}); | ||
``` | ||
|
||
|
||
|
||
## Usage | ||
|
||
Start by adding the `data-equalizer-row` attribute to an element that contains the elements you want to equalize. If you want the elements to only equalize on some breakpoints and not others, including the `data-equalizer-on` attribute and pass it a comma separated list of breakpoint names to equalize on. | ||
|
||
|
||
|
||
Add the attribute `data-equalizer` to all elements that should be equalized. | ||
|
||
### Groups | ||
|
||
You may also specify a "group" of elements to equalize. This is helpful if you want to equalize multiple groups of elements in the same container. | ||
|
||
To create an equalizer group, simply pass the name of the group to the `data-equalizer-row` attribute. | ||
|
||
``` | ||
<div class="my-element" data-equalizer-row="my-group"> | ||
... | ||
</div> | ||
``` | ||
|
||
From there, you must enter the group name into the `data-equalizer` attribute for each element you want associated with that group. | ||
|
||
*Note: Elements can only have one `data-equalizer-row` attribute.* | ||
|
||
## Examples | ||
|
||
Equalize only on all breakpoints. | ||
|
||
``` | ||
<div class="demo_row" data-equalizer-row> | ||
<div class="demo_item" data-equalizer> | ||
<img src="//picsum.photos/500?random" width="500" height="500" alt="demo image"> | ||
</div> | ||
<div class="demo_item" data-equalizer> | ||
<img src="//picsum.photos/500/900?random" width="500" height="900" alt="demo image"> | ||
</div> | ||
<div class="demo_item" data-equalizer> | ||
<img src="//picsum.photos/500/250?random" width="500" height="250" alt="demo image"> | ||
</div> | ||
</div> | ||
``` | ||
|
||
|
||
Equalize only on `medium` and `xlarge`. | ||
|
||
``` | ||
<div class="demo_row" data-equalizer-row data-equalizer-on="medium,xlarge"> | ||
<div class="demo_item" data-equalizer> | ||
<img src="//picsum.photos/500?random" width="500" height="500" alt="demo image"> | ||
</div> | ||
<div class="demo_item" data-equalizer> | ||
<img src="//picsum.photos/500/900?random" width="500" height="900" alt="demo image"> | ||
</div> | ||
<div class="demo_item" data-equalizer> | ||
<img src="//picsum.photos/500/250?random" width="500" height="250" alt="demo image"> | ||
</div> | ||
</div> | ||
``` | ||
|
||
Equalize multiple groups of elements. | ||
|
||
``` | ||
<div class="demo_row" data-equalizer-row="group1" data-equalizer-on="medium,xlarge"> | ||
<div class="demo_item" data-equalizer="group1"> | ||
<img src="//picsum.photos/500?random" width="500" height="500" alt="demo image"> | ||
</div> | ||
<div class="demo_item" data-equalizer="group1"> | ||
<img src="//picsum.photos/500/900?random" width="500" height="900" alt="demo image"> | ||
</div> | ||
<div class="demo_item" data-equalizer="group1"> | ||
<img src="//picsum.photos/500/250?random" width="500" height="250" alt="demo image"> | ||
</div> | ||
</div> | ||
<div class="demo_row" data-equalizer-row="group2"> | ||
<div class="demo_item demo_item--green" data-equalizer="group2"> | ||
<img src="//picsum.photos/150?random" width="150" height="150" alt="demo image"> | ||
</div> | ||
<div class="demo_item demo_item--green" data-equalizer="group2"> | ||
<img src="//picsum.photos/75?random" width="75" height="75" alt="demo image"> | ||
</div> | ||
<div class="demo_item demo_item--green" data-equalizer="group2"> | ||
<img src="//picsum.photos/250?random" width="250" height="250" alt="demo image"> | ||
</div> | ||
</div> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,9 @@ img { | |
background: green; | ||
} | ||
} | ||
|
||
&_row { | ||
display: inline-block; | ||
width: 100%; | ||
} | ||
} |
Oops, something went wrong.