Media object
Documentation and examples for Bootstrap’s media object to construct highly repetitive components like blog comments, tweets, and the like.
Example
The media object helps build complex and repetitive components where some media is positioned alongside content that doesn’t wrap around said media. Plus, it does this with only two required classes thanks to flexbox.
Below is an example of a single media object. Only two classes are required—the wrapping
.media
and the
.media-body
around your content. Optional padding and margin can be controlled through
spacing
utilities.
Media heading
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.<div class="media">
<img src="../assets/img/avatars/43.jpg" class="mr-3" height="100" alt="...">
<div class="media-body">
<h5 class="mb-2">Media heading</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac
nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</div>
Nesting
Media objects can be infinitely nested, though we suggest you stop at some point. Place nested .media
within the .media-body
of a parent media object.
Media heading
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.<div class="dropup">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">
Another action
</a>
<a class="dropdown-item" href="#">
Something else here
</a>
<a class="dropdown-item" href="#">
Anything else
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">
Cool, Support Divider
</a>
</div>
</div>
Alignment
Media in a media object can be aligned with flexbox utilities to the top (default), middle, or end of
your .media-body
content.
Center-aligned media
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Bottom-aligned media
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
<div class="media align-items-center">
<img src="../assets/img/avatars/43.jpg" class="mr-3" height="64" alt="...">
<div class="media-body">
<h5 class="mb-2">Center-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc
ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p class="mb-0">Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum
sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
<div class="media mt-5">
<img src="../assets/img/avatars/43.jpg" class="align-self-end mr-3" height="64" alt="...">
<div class="media-body">
<h5 class="mt-0">Bottom-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc
ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p class="mb-0">Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum
sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
Media list
Because the media object has so few structural requirements, you can also use these classes on list
HTML elements. On your <ul>
or <ol>
, add the .list-unstyled
to remove any browser default list styles, and then
apply .media
to your <li>
s. As always, use spacing utilities wherever needed to fine
tune.
-
Creative Ideas
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio. -
Excellent Features
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio. -
Modern Design
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio.
<ul class="list-unstyled">
<li class="media">
<div class="iconbox iconbox-xl bg-primary text-white">
<i class="la la-area-chart la-2x"></i>
</div>
<div class="media-body pl-4">
<h5 class="mt-0 mb-1"> Creative Ideas</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio.
</div>
</li>
<li class="media my-5">
<div class="iconbox iconbox-xl bg-secondary text-white">
<i class="la la-lightbulb-o la-2x"></i>
</div>
<div class="media-body pl-4">
<h5 class="mt-0 mb-1">Excellent Features</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio.
</div>
</li>
<li class="media my-5">
<div class="iconbox iconbox-xl bg-info text-white">
<i class="la la-magic la-2x"></i>
</div>
<div class="media-body pl-4">
<h5 class="mt-0 mb-1">Modern Design
</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
Cras purus odio.
</div>
</li>
</ul>