Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrapping text around a div with CSS

Tags:

css

xhtml

I am trying to get a text to wrap around a div in my XHTML. My XHTML looks like so....

<div id="cont-content">   <p>content</p>  <p>more content</p>  <div id="content-sidebar">   BLALALALALLAAL   </div>    </div> 

And my CSS looks like...

#content-sidebar {     display: block;     float: right;     width: 270px;     height: 400px;     border: 1px solid red; } 

Can you see any reason why the text will not wrap around this Div?

like image 476
alex Avatar asked Dec 19 '08 05:12

alex


People also ask

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 break a long text in CSS?

The <wbr> element If you know where you want a long string to break, then it is also possible to insert the HTML <wbr> element. This can be useful in cases such as displaying a long URL on a page.


1 Answers

Yep you got it. The #content-sidebar should be before all the texts which are supposed to wrap it. Like this:

<div id="cont-content">  <div id="content-sidebar">   BLALALALALLAAL   </div>  <p>content</p>  <p>more content</p>     </div> 
like image 91
datasn.io Avatar answered Sep 19 '22 17:09

datasn.io