Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap Media Object

Bootstrap Media Object (Media Object)

In this chapter we will explain media objects (Media Object) in Bootstrap, such as images, videos, audio, etc. The styles of media objects can be used to create various types of components (such as blog comments), where we can mix images and text, with images aligned left or right. Media objects can achieve the mixing of media and text with less code.

Next let's look at an example:

Example

<div class="media">
<div class="media-left">
<img src="img_avatar1.png" class="media-object" style="width:60px" div>
<div class="media-body">
<h4 class="media-heading">

Left align

h4

<

p

This is some sample text...

p

div

div

<div class="media">
<div class="media-body">
<h4 class="media-heading">

Left align

h4

<

p

This is some sample text...

p

div

<div class="media-right">
<img src="img_avatar1.png" class="media-object" style="width:60px" div div>

Try it »

The result is as follows:

Example Parsing

in

element, add the .media class to create a media object.

Use .media-left class makes the media object (image) align left, and the .media-right class achieves right alignment.

Text content goes in a div with class="media-body"; for a left-aligned image, put it before class="media-body"; for a right-aligned image, put it after class="media-body".

In addition, you can also use the .media-heading class to set the title.

Let's look at the following example about the media object list .media-list:

Top, bottom, and center alignment

Example

<div class="media">
<div class=">

media-left media-top

"

<img src="img_avatar1.png" class="media-object" style="width:60px" div>
<div class="media-body">
<h4 class="media-heading" Top h4>
<p>

This is some sample text...

p

div

div

<div class="media">
<div class=">

media-left media-middle

"

<img src="img_avatar1.png" class="media-object" style="width:60px" div>
<div class="media-body">
<h4 class="media-heading" Centering h4>
<p>

This is some sample text...

p

div

div

<div class="media">
<div class=">

media-left media-bottom

"

<img src="img_avatar1.png" class="media-object" style="width:60px" div>
<div class="media-body">
<h4 class="media-heading" Bottom h4>
<p>

This is some sample text...

p

div

div

Try it »

The result is as follows:

Nested Media Objects

A media object can also contain multiple media objects:

Example

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-1>
<small>
<i>

Posted on February 19, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-2>
<small>
<i>

Posted on February 19, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-3>
<small>
<i>

Posted on February 19, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

div

div

div

div

div

div

Try it »

Example

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-1>
<small>
<i>

Posted on February 19, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-2>
<small>
<i>

Posted on February 20, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-3>
<small>
<i>

Posted on February 21, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

div

div

div

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-4>
<small>
<i>

Posted on February 20, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

div

div

div

div

<div class="media">
<div class="media-left">
<img src="https://static.jyshare.com/images/mix/img_avatar.png" class="media-object" style="width:45px" div>
<div class="media-body">
<h4 class="media-heading" RUNOOB-5>
<small>
<i>

Posted on February 19, 2016

i

small

h4

<

p

This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text. This is some sample text.

p

div

div

div

Try it »