user966582
user966582

Reputation: 3323

float content of a div

I have a fixed width div which I want to display on the right side in a container. On the left side I want to display a div so that its text expands below the right side div after the right div ends. Please see the image below:

enter image description here

Here's what I'm currently trying:

HTML:

<div class="wrapper">
    <div class="left">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu ipsum augue. </div>
     <div class="right">float right.</div>
</div>

CSS:

.wrapper{
    overflow: hidden;
    border: 1px solid red;
    width: 300px;
}

.left{
    float: left;
    width: 200px;
    background: brown;
}

.right{
    float: right;
    width: 100px;
    background: green;
}

JSFiddle: http://jsfiddle.net/qyrKY/

Upvotes: 2

Views: 66

Answers (1)

j08691
j08691

Reputation: 208002

Change the order of your divs to the following:

<div class="wrapper">
    <div class="right">float right.</div>
    <div class="left">Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu ipsum augue. Nulla ac turpis sem, vitae iaculis diam. Pellentesque nisl magna, gravida tempus laoreet in, bibendum eget dolor. Morbi convallis sem faucibus turpis viverra vestibulum. Nam at urna elit, eget elementum elit. Donec pretium placerat mauris ut blandit. Phasellus sit amet est ante, quis dignissim metus. Mauris id neque ligula, sit amet convallis nunc.</div>
</div>

And change your left CSS class to :

.left {
    background: brown;
}

jsFiddle example

Upvotes: 5

Related Questions