<metaname="description"content="Documentation and examples for Bootstrap’s media object to construct highly repetitive components like blog comments, tweets, and the like.">
<metaname="author"content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<metaname="twitter:description"content="Documentation and examples for Bootstrap’s media object to construct highly repetitive components like blog comments, tweets, and the like.">
<metaproperty="og:description"content="Documentation and examples for Bootstrap’s media object to construct highly repetitive components like blog comments, tweets, and the like.">
<pclass="bd-lead">Documentation and examples for Bootstrap’s media object to construct highly repetitive components like blog comments, tweets, and the like.</p>
<p>The <ahref="http://www.stubbornella.org/content/2010/06/25/the-media-object-saves-hundreds-of-lines-of-code/">media object</a> 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.</p>
<p>Below is an example of a single media object. Only two classes are required—the wrapping <codeclass="highlighter-rouge">.media</code> and the <codeclass="highlighter-rouge">.media-body</code> around your content. Optional padding and margin can be controlled through <ahref="http://getbootstrap.com/docs/4.1/utilities/spacing/">spacing utilities</a>.</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.
</div>
</div>
</div>
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><div</span><spanclass="na">class=</span><spanclass="s">"media"</span><spanclass="nt">></span>
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.
<h5id="flexbug-12-inline-elements-arent-treated-as-flex-items">Flexbug #12: Inline elements aren’t treated as flex items</h5>
<p>Internet Explorer 10-11 do not render inline elements like links or images (or <codeclass="highlighter-rouge">::before</code> and <codeclass="highlighter-rouge">::after</code> pseudo-elements) as flex items. The only workaround is to set a non-inline <codeclass="highlighter-rouge">display</code> value (e.g., <codeclass="highlighter-rouge">block</code>, <codeclass="highlighter-rouge">inline-block</code>, or <codeclass="highlighter-rouge">flex</code>). We suggest using <codeclass="highlighter-rouge">.d-flex</code>, one of our <ahref="http://getbootstrap.com/docs/4.1/utilities/display/">display utilities</a>, as an easy fix.</p>
<p><strong>Source:</strong><ahref="https://github.com/philipwalton/flexbugs#flexbug-12">Flexbugs on GitHub</a></p>
<p>Media objects can be infinitely nested, though we suggest you stop at some point. Place nested <codeclass="highlighter-rouge">.media</code> within the <codeclass="highlighter-rouge">.media-body</code> of a parent media object.</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.
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>
</div>
</div>
</div>
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><div</span><spanclass="na">class=</span><spanclass="s">"media"</span><spanclass="nt">></span>
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.
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>Media in a media object can be aligned with flexbox utilities to the top (default), middle, or end of your <codeclass="highlighter-rouge">.media-body</code> content.</p>
<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>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>
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><div</span><spanclass="na">class=</span><spanclass="s">"media"</span><spanclass="nt">></span>
<spanclass="nt"><p></span>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.<spanclass="nt"></p></span>
<spanclass="nt"><p></span>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.<spanclass="nt"></p></span>
<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>
<pclass="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>
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><div</span><spanclass="na">class=</span><spanclass="s">"media"</span><spanclass="nt">></span>
<spanclass="nt"><p></span>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.<spanclass="nt"></p></span>
<spanclass="nt"><p</span><spanclass="na">class=</span><spanclass="s">"mb-0"</span><spanclass="nt">></span>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.<spanclass="nt"></p></span>
<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>
<pclass="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>
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><div</span><spanclass="na">class=</span><spanclass="s">"media"</span><spanclass="nt">></span>
<spanclass="nt"><p></span>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.<spanclass="nt"></p></span>
<spanclass="nt"><p</span><spanclass="na">class=</span><spanclass="s">"mb-0"</span><spanclass="nt">></span>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.<spanclass="nt"></p></span>
<p>Change the order of content in media objects by modifying the HTML itself, or by adding some custom flexbox CSS to set the <codeclass="highlighter-rouge">order</code> property (to an integer of your choosing).</p>
<divclass="bd-example">
<divclass="media">
<divclass="media-body">
<h5class="mt-0 mb-1">Media object</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.
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><div</span><spanclass="na">class=</span><spanclass="s">"media"</span><spanclass="nt">></span>
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>Because the media object has so few structural requirements, you can also use these classes on list HTML elements. On your <codeclass="highlighter-rouge"><ul></code> or <codeclass="highlighter-rouge"><ol></code>, add the <codeclass="highlighter-rouge">.list-unstyled</code> to remove any browser default list styles, and then apply <codeclass="highlighter-rouge">.media</code> to your <codeclass="highlighter-rouge"><li></code>s. As always, use spacing utilities wherever needed to fine tune.</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.
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.
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>
</li>
</ul>
</div>
<divclass="bd-clipboard"><buttonclass="btn-clipboard"title=""data-original-title="Copy to clipboard">Copy</button></div><figureclass="highlight"><pre><codeclass="language-html"data-lang="html"><spanclass="nt"><ul</span><spanclass="na">class=</span><spanclass="s">"list-unstyled"</span><spanclass="nt">></span>
<spanclass="nt"><h5</span><spanclass="na">class=</span><spanclass="s">"mt-0 mb-1"</span><spanclass="nt">></span>List-based media object<spanclass="nt"></h5></span>
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.
<spanclass="nt"><h5</span><spanclass="na">class=</span><spanclass="s">"mt-0 mb-1"</span><spanclass="nt">></span>List-based media object<spanclass="nt"></h5></span>
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.
<spanclass="nt"><h5</span><spanclass="na">class=</span><spanclass="s">"mt-0 mb-1"</span><spanclass="nt">></span>List-based media object<spanclass="nt"></h5></span>
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.