Foundation CSS Equalizer
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is built on Saas-like bootstrap. It is more sophisticated, flexible, and easily customizable. It also comes with CLI, so it’s easy to use it with module bundlers. It offers the Fastclick.js tool for faster rendering on mobile devices.
The Equalizer component helps to make multiple website elements of the same height. In modern browsers, sometimes the elements are not of the same height, as shown below:
Thus, this makes the website look ugly. This type of problem can be solved easily by using the Equalizer component of Foundation CSS by making the height of all three columns equal.
Foundation CSS Equalizer Attributes:
- data-equalizer: This attribute is added to the parent container component which holds the child elements which will be equalized.
- data-equalize-on: This attribute holds the value of the screen size for which the elements shall be equalized. It can have values like small, large, and medium respectively. It is added to the parent component.
- data-equalizer-watch: This attribute is added to the child elements. It contains the value of the parent equalizer id.
- data-equalize-by-row: This attribute is very useful in distributing elements in rows.
- data-equalize-on-stack: This attribute enables the height equalization of elements when stacked in a row.
Foundation CSS Equalizer Class:
- grid-container: This class helps us to center the grid in the screen with margin and padding on both sides.
- grid-x: This class makes the grid arranged on the x-axis.
- grid-margin-x: This class helps to give margin to the grid elements along the x-axis.
- cell: This class is used to identify each of the elements inside the grid that needs to arrange.
- medium-4: This class is a Foundation CSS media query class. This class makes an element to be four-column width on a medium screen.
<div class="grid-x grid-margin-x" data-equalizer="equalizer1" data-equalize-on="medium"> <div class="cell medium-4"> <div data-equalizer-watch="equalizer1"> ... </div> </div> </div>
Example 1: In this example, we added the equalizer to equalize all the three cells of the grid to make them equal in height irrespective of containing variable-sized images and text.
Example 2: In the example, we have nested used a nested equalizer to make equalize the content inside one of the boxes of the container grid. We have used the “data-equalize-on-stack” attribute.