Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap3 media object <div class="media"> not works

Follow the instruction at http://getbootstrap.com/components/#media, I copied the code:

<div class="container">
<div class="media">
      <a class="media-left media-bottom" href="#">
        <img src="https://www.gravatar.com/avatar/16250bf5bb2c9f970cdc0f43c830b34f?s=32&d=identicon&r=PG">
      </a>
      <div class="media-body">
        <h4 class="media-heading">Bottom aligned media</h4>
        <p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. 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>

at jsfiddle http://jsfiddle.net/x3a1c40h/3/

As we can see the img appears on the top of the text, but not on the left, why is that?

Thank you!

like image 506
SetupX Avatar asked Dec 01 '22 18:12

SetupX


2 Answers

Just like the doc said

pull-left and pull-right deprecated for that use as of v3.3.0.

And the version of bootstrap you were using in the jsfiddle was 3.0.

Change the external source from

http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js

to

http://netdna.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css http://netdna.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js

resolves the problem.

see the updated link http://jsfiddle.net/x3a1c40h/7/

like image 27
Alan Dong Avatar answered Dec 04 '22 00:12

Alan Dong


Add pull-left to img

<div class="container">
<div class="media">
      <a class="media-left media-bottom" href="#">
        <img class="pull-left" src="https://www.gravatar.com/avatar/16250bf5bb2c9f970cdc0f43c830b34f?s=32&d=identicon&r=PG">
      </a>
      <div class="media-body">
        <h4 class="media-heading">Bottom aligned media</h4>
        <p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. 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>

The classes .pull-left and .pull-right also exist and were previously used as part of the media component, but are deprecated for that use as of v3.3.0. They are approximately equivalent to .media-left and .media-right, except that .media-right should be placed after the .media-body in the html.

like image 101
Miomir Dancevic Avatar answered Dec 04 '22 00:12

Miomir Dancevic