Foundation CSS Media Object
Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. It has numerous pre-built website component that makes our website look professional and improves the user experience of the website. One such useful component in Foundation CSS is Media Object.
In this article, we will learn about the Media Object component of Foundation CSS. The Media object is a very useful component for displaying an image along with some content usually text in different alignment with it. We can also create nested media objects and grids using the different features of the media object.
- media-object: This class is the container class for creating media objects.
- media-object-section: This class denotes the different sections of the media object.
- stack-on-small: This class will allow the images will get a width of 100% and the text will resize and even be stacked when the screen size becomes small.
Section Alignment: In Foundation CSS, each section is aligned to the top by default. Now, we can change the alignment of each section using the below classes:
- middle: This class aligns the section to the middle of the media object container.
- bottom: This class aligns the section to the bottom of the media object container.
- align-self-middle: This class aligns each section to the middle.
- align-self-bottom: This class aligns each section to the top of the media object container.
- align-middle: This class aligns all the child sections of the media object container to the middle all at once.
- align-bottom: This class aligns all the child sections of the media object container to the bottom all at once.
<div class="media-object"> ... </div>
Example 1: The below example is of two media objects. The first one is bottom aligned and the second one is middle aligned. But both are responsive.
Example 2: We can easily create a nested media objects using by inserting a media object inside another media object.