Matthew
Matthew

Reputation: 11250

Expand DIV width that is next to a floated div

I want to expand the width of a DIV that is next to a right floated div.

If that other div is left floated, I have no problem:
http://jsfiddle.net/ykyVv/

But I don't know how to do it if the other div is floated to the right:
http://jsfiddle.net/FMyjU/

(notice that the divs are not next to each other, I also tried to add float:left to the first div but then it doesn't expand anymore)

Upvotes: 2

Views: 1399

Answers (2)

Matt Wolfe
Matt Wolfe

Reputation: 9284

Is this what you are looking for?

http://jsfiddle.net/MYRde/

Upvotes: 6

animuson
animuson

Reputation: 54719

Put the second division before the first one. You might also want to add a margin-right to the div1 which is equivalent to the width of the right-floated one.
A general rule of floating elements: right then left.

Updated jsFiddle. or Fiddle with right margin.

Upvotes: 2

Related Questions