I want to use a media object in Bootstrap v5.0.0-alpha1, but how?
In Bootstrap 3 & 4, I’m using it like this:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container mt-3">
<h2>Media Object</h2>
<p>Create a media object with the .media and .media-body classes:</p>
<div class="media border p-3">
<img src="https://cdn.pixabay.com/photo/2016/11/18/23/38/child-1837375_960_720.png" alt="John Doe"
class="mr-3 mt-3 rounded-circle" style="width:60px;">
<div class="media-body">
<h4>John Doe <small>Posted on February 19, 2016</small></h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua.</p>
</div>
</div>
</div>
In v5.0.0-alpha1, which class can I use for a media object? I was unable to find any class named ‘media’ in Bootstrap 5.
3
Answers
Since Bootstrap dropped the "media object" in version 5, you will have to use the utility classes instead.
Bootstrap 5’s documentation illustrates how to use the Cards to achieve the old Media Object layout. https://getbootstrap.com/docs/5.0/components/card/#horizontal
For example:
For those of you who are just using the grid parts of Bootstrap, you could achieve a media object layout like this:
col-auto
shrink-wraps the column to the width of the content (in the above example, an image) andcol
simply takes up (or distributes, if there’s more than one) the remaining space. See the documentation, for more information.