Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Image on right side of page with text not wrapping around it

Tags:

css

This is probably a simple question, but I can't figure it out. I would like to use CSS to put an image on the right side of a page and not wrap text around it. I would like it like this:

                ------------
                |    img   |
                |          |
                ------------
text text text text text text
text ....

If I do a float:right on the image, I get this:

text text text  ------------
text text text  |   img    |
text text text  |          |
text text text  ------------
text text text text text text
text ...

I could easily use tables to do this, but I would like pure CSS.

like image 205
Starkey Avatar asked Sep 17 '10 20:09

Starkey


2 Answers

Something similar to this should work:

<div>
  <div style="width: 100%">
    <img style="float:right;">
  </div>
  <div>
    text
  </div>
</div>
like image 125
Rohrbs Avatar answered Nov 13 '22 05:11

Rohrbs


<div>
        <img src="img.jpg" style="float:right;" />
        <div style="clear:right;">
            <!-- text here -->
        </div>

</div>

perhaps?

like image 34
Ross Avatar answered Nov 13 '22 06:11

Ross