Chris
Chris

Reputation: 7310

Prevent a span from overlapping a div

I have a div container and a span container very close to each other (span on the left, div on the right). Is there a way for the span to realize when it is within, lets say 5px, of the div so that it goes to the next line?

In the diagram, the left box is where the span containers will be containing text. The right box is the div container that text can not go on

_______________________
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|                     |
|              -----------------------
|              |                     |
|              |                     |
|              |                     |
|              |                     |
|              |                     |
_______________|                     |
               |                     |
               |                     |
               |                     |
               -----------------------

Upvotes: 1

Views: 4060

Answers (1)

Hello World
Hello World

Reputation: 1437

Stick the span inside another div and put a float on it

html:

<div class="LeftFloat">
   <span>
   </span>
<div>

CSS:

.LeftFloat
{
   float:left;
}

Upvotes: 1

Related Questions