What are media objects in Bootstrap 4?
Overview
In Bootstrap, media objects are the easiest method used for displaying images or videos that are either aligned left or right with the content. This media objects method is used where the data is positioned along with the content to build up the recursive components of the content, as we do in tweets.
Types of media objects
Type | Description |
Basic media objects | These are created when the |
Aligned media image | To align a media image, we add the image to the right/left/vertical/horizontal side after the content class. |
Nested media objects | A nested media object is created when a media object is placed inside another media object. |
Media lists | Media lists are created by placing media objects inside lists. |
Code
Now, let’s look at a code example:
Explanation
-
Lines 11–17: In the code given above, we create the
Media1class in which there is an image of Tom. In themedia-bodyclass of theMedai1class, there is some heading or text. ThisMedia1class represents the basicmedia. -
Lines 19–32: We create the
Media2andMedia3classes in which there are two images of Harry and Eric, respectively. In themedia-bodyclasses of theMedia2andMedia3class, some heading and text are given. TheMedia2andMedia3classes represent the nestedmediaobjects.