rainy
rainy

Reputation: 1587

Bootstrap - How to make text wrap around an image on small devices?

I'm just getting started with Bootstrap. Below is a snapshot of my page.

enter image description here

My CSS is

.snippet img{
width: 150px;
max-width: 100%;
height:auto;


 }

@media(max-width: 767px) {
.snippet img{

    width:100px;
    float: right;
    max-width: 100px;
    height: auto;
    margin-left: 10px;
    margin-right: 10px;
    }
}

And here is my HTML:

<h2>About the venue</h2>
<div class="media-body snippet" >
    <a class="pull-right" href="venue.php">
            <img  src="images/venue.jpg" alt="illustration"></a>
    <p>this is the paragraph ... </p>       
</div>

I want the image to be hanging like that on big screen. However, on small devices I would like to get the text to wrap around the image. How can I do that?

Any help would be appreciated!

Upvotes: 8

Views: 60299

Answers (6)

BLoB
BLoB

Reputation: 9725

I just use the following: float is all that's needed, a bit of padding for visuals:

<div class="float-right pl-3 pb-3">
    <img src="https://i.pinimg.com/474x/4a/c7/3b/4ac73b5c8ef5d397ab535ac1631642a7.jpg" class="shadow img-fluid">
</div>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>

Upvotes: 1

Miklos Sebestyen
Miklos Sebestyen

Reputation: 1

You have to add the following class to your html code: "img-responsive pull-left"

For example:

<img  src="IMG/img.jpg" alt="about image" class="img-rounded img-responsive pull-left">

Upvotes: 0

Vikas Sharma
Vikas Sharma

Reputation: 80

YOu can try this

<style>
    .snippet {width: 250px;}
    .snippet img{ width: 150px; height:auto; float: left; }

  </style>
 </head>
 <body>
<div class="media-body" >
    <div class="snippet">
        <a class="pull-right" href="venue.php"><img  src="https://i.sstatic.net/Fa34B.png" alt="illustration"></a>
        <p>this is the paragraph ...  </p>      
    </div>
</div>

Upvotes: 2

MaiKaY
MaiKaY

Reputation: 4482

why you dont use this? its also smarter ;) http://getbootstrap.com/components/#thumbnails-custom-content

EDIT

include code from bootstrap doc

<div class="row">
<div class="col-sm-6 col-md-4">
    <div class="thumbnail">
        <img data-src="holder.js/300x200" alt="...">

        <div class="caption">
            <h3>Thumbnail label</h3>

            <p>...</p>

            <p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
        </div>
    </div>
</div>

Upvotes: 9

Vikas Sharma
Vikas Sharma

Reputation: 80

Try this

<div style="width: 150px;">
<img src="https://i.sstatic.net/Fa34B.png" align="left" width="100" height="100"> This is text  This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text This is text
  </div>

Upvotes: 1

sush
sush

Reputation: 379

Add this line of css code

display:inline;

Upvotes: 0

Related Questions