Equalizer
Equalizer is a great way to create equal height content on your page.
Panel 1
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.
Panel 2
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Aliquam tincidunt mauris eu risus.
- Vestibulum auctor dapibus neque.
Panel 3
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
Basic
You can create an equal height container using a few data attributes. Apply the data-equalizer
attribute to a parent container. Then apply the data-equalizer-watch
attribute to each element you'd like to have an equal height. The height of data-equalizer-watch
attribute will be equal to that of the tallest element.
HTML
<div class="row" data-equalizer>
<div class="large-6 columns panel" data-equalizer-watch>
...
</div>
<div class="large-6 columns panel" data-equalizer-watch>
...
</div>
</div>
Rendered HTML
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Responsive Equalizer
You can specify media queries for which equalizer should activate on. Apply the data-equalizer-mq
attribute to the parent container. Set the value of the attribute to the same media queries you are use to using in Foundation. If you use an unknown media query, Equalizer will ignore the media query request. This is particularly useful if you have set equalize_on_stack
to true
.
HTML
<div class="row" data-equalizer data-equalizer-mq="large-up">
<div class="medium-6 columns panel" data-equalizer-watch>
...
</div>
<div class="medium-6 columns panel" data-equalizer-watch>
...
</div>
</div>
Rendered HTML
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Nested Elements
You can also nest "equalized" elements in other Equalizer elements. Apply the data-equalizer
attribute to a parent container and assign a unique name to it. Then apply the data-equalizer-watch
attribute to each nested element with the corresponding name. The height of data-equalizer-watch
attribute will be equal to that of the tallest element.
HTML
<div class="row" data-equalizer="foo">
<div class="medium-4 columns">
<div class="panel" data-equalizer-watch="foo">
<h3>Parent panel</h3>
<div class="row" data-equalizer="bar">
<div class="panel" data-equalizer-watch="bar">
...
</div>
<div class="panel" data-equalizer-watch="bar">
...
</div>
<div class="panel" data-equalizer-watch="bar">
...
</div>
</div>
</div>
</div>
<div class="medium-4 columns">
<div class="callout panel" data-equalizer-watch="foo">
...
</div>
</div>
<div class="medium-4 columns">
<div class="panel" data-equalizer-watch="foo">
...
</div>
</div>
</div>
Rendered HTML
Rendered HTML
Parent panel
Nested Panel 1
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.
Nested Panel 2
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.
Nested Panel 3
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.
Panel 2
- Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
- Aliquam tincidunt mauris eu risus.
- Vestibulum auctor dapibus neque.
Panel 3
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
Advanced
Perhaps you need to create items that are positioned at the bottom of your input. For example Sign Up buttons on some pricing tables.
HTML
<div class="row" data-equalizer>
<div class="large-6 columns">
<ul class="pricing-table" data-equalizer-watch>
...
<li class="cta-button"><a class="button" href="#">Buy Now</a></li>
</ul>
</div>
<div class="large-6 columns">
<ul class="pricing-table" data-equalizer-watch>
...
<li class="cta-button"><a class="button" href="#">Buy Now</a></li>
</ul>
</div>
</div>
Rendered HTML
- Standard
- $99.99
- 1 Database
- 5GB Storage
- 20 Users
- Cadillac
- $999.99
- ∞ Databases
- ∞ Storage
- ∞ Users
- SSL Support
- 24/7 Support
Using the Javascript
Before you can use Equalizer you'll want to verify that jQuery and foundation.js
are available on your page. You can refer to the Javascript documentation on setting that up.
Just add foundation.equalizer.js
AFTER the foundation.js
file. Your markup should look something like this:
<body>
...
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.equalizer.js"></script>
<!-- Other JS plugins can be included here -->
<script>
$(document).foundation();
</script>
</body>
Required Foundation Library: foundation.equalizer.js
Optional Javascript Configuration
JS
$(document).foundation({
equalizer : {
// Specify if Equalizer should make elements equal height once they become stacked.
equalize_on_stack: false,
// Allow equalizer to resize hidden elements
act_on_hidden_el: false
}
});
Callbacks
There are two ways to bind to callbacks in your equalizers.
Deprecation Notice
Previous versions of the equalizer plugin emitted un-namespaced before-height-change
and after-height-change
events, however, these have been replaced by the namespaced before-height-change.fndtn.equalizer
and after-height-change.fndtn.equalizer
events. The un-namespaced events have been fully deprecated.
Callback Function
$(document).foundation({
equalizer: {
before_height_change: function(){
// do something before the height changes
},
after_height_change: function(){
// do something after the height changes
}
}
});
Events
$(document).on('before-height-change.fndtn.equalizer', function(){
// do something before the height changes
});
$(document).on('after-height-change.fndtn.equalizer', function(){
// do something after the height changes
});
Adding New Content After Page Load
If you add new content after the page has been loaded, you will need to reinitialize the Foundation JavaScript by running the following:
$(document).foundation();
Reflow will make Foundation check the DOM for any elements and re-apply any listeners to them.
$(document).foundation('equalizer', 'reflow');