Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap text around a div?

Tags:

html

css

I have a container div around my coinslider. I would like to wrap text around this container div. How does one go about achieving this?

Right now the my HTML is setup like this:

<p> <!-- LOTS OF TEXT --> </p>
<div id="mycontainer"> <!-- coinslider inside --></div>

My CSS is setup like this:

#mycontainer {
position: relative;
float: right;
width: 500;
height: 334;
}
like image 861
Szuturon Avatar asked Nov 08 '12 19:11

Szuturon


People also ask

How do I wrap text in a div?

If you've faced the situation when you need to wrap words in a <div>, you can use the white-space property with the "pre-wrap" value to preserve whitespace by the browser and wrap the text when necessary and on line breaks. Also, you'll need the word-wrap property.

How do I wrap text in a box CSS?

You have to set 'display:inline-block' and 'height:auto' to wrap the content within the border. Show activity on this post. Two ways are there. No need to mention height in this it will be auto by default.

How do you wrap text around a shape?

With your Text Tool, select your text and press Command + A (Mac) or Control + A (PC) to highlight all. Hold Command or Control and click and drag your text to the inside of your shape. This will automatically shift your text to wrap around the inside edge of your shape.


2 Answers

<div>
    <div  style="float:left; width: 150px; height: 150px; margin: 10px; background-color: #ff0000;">
        <!--your image or text--> 
    </div>
    <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</p>
    <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?</p>
</div>
like image 188
TechFreak Avatar answered Oct 19 '22 08:10

TechFreak


Encase you Div in another div and Give the float property to it ...

<div id="main">
    <div id="mycontainer"> <!-- coinslider inside --></div>
</div>
<p> <!-- LOTS OF TEXT --> </p>

#main
{
    float:right;
}
#mycontainer 
{
    width: 500px;
    height: 334px;
    background-color:  gold;
}

Check Fiddle

OR

P should come after Div

   <div id="mycontainer"> <!-- coinslider inside --></div>

    <p> <!-- LOTS OF TEXT --> </p>

#mycontainer 
{
    float:right;
    width: 500px;
    height: 334px;
    background-color:  gold;
}

**

​Fiddle

**

like image 21
Sushanth -- Avatar answered Oct 19 '22 10:10

Sushanth --