make floating divs fill whitespace

css float
how to make aside ( float: right)
floating div right side of page
div float left
float position
clear float
float right not working
float top right

I have the problem that I have 3 divs and when one div is longer than the other div, it creates some whitespace. I would like to have the whitespace gone and the divs connect. This is what I have now:

.one{
background: lightgreen;
height: 300px;
width:100px;
float: left;
margin: 5px;
}
.two{
background: brown;
height: 500px;
width: 100px;
float: left;
margin: 5px;
}
.main{
width: 220px;

}
.info{
background: orange;
height: 200px;
width:100px;
float: left;
margin: 5px;

}
<div class='main'>
<div class='info'>

to this one

</div>
<div class='two'>



</div>
<div class='two'>
this one should be up


</div>
<div class='two'>



</div>
<div class='one'>



</div>
</div>

That is not possible, when the class .two is floating left. You have to use float:right for the class .two instead.

.one{
background: lightgreen;
height: 300px;
width:100px;
float: left;
margin: 5px;
}
.two{
background: brown;
height: 500px;
width: 100px;
float: right;
margin: 5px;
}
.main{
width: 220px;

}
<div class='main'>
<div class='one'>

to this one

</div>
<div class='two'>



</div>
<div class='one'>
this one should be up


</div>
</div>

CSS float creating white space, I have three divs first and second have width 60% and are floated left third has width 30% floated right. IE7 works fine the third div appears from  I have three divs first and second have width 60% and are floated left third has width 30% floated right. IE7 works fine the third div appears from the top of the page. latest browsers floats element besides the 2nd div. I cannot change the order of the divs as its created through CMS. and have access only to CSS. Sample code looks like this

You will need to float the .two class to the right.

float: right;

Hope this helps :>

.one{
background: lightgreen;
height: 300px;
width:100px;
float: left;
margin: 5px;
}
.two{
background: brown;
height: 500px;
width: 100px;
float: right;
margin: 5px;
}
.main{
width: 220px;
}
<div class='main'>
<div class='one clearfix'>

to this one

</div>
<div class='two'>



</div>
<div class='one'>
this one should be up


</div>
</div>

How to make a div fill a remaining horizontal space using CSS , How to Specify Divider gap in Square Grid using Bootstrap ? How to make a div fill a remaining horizontal space using CSS? The  I want the left div to fit its contents (it's not possible to know the width in advance), and I want the right div to always fill the remaining horizontal space. At the moment the left float works the way I want it to but the right float also fits its contents and doesn't expand to fill the rest of the screen.

Add float:right to .two div element

Everything You Need to Know About Floating a Div, We all have to float a div, but unless you know the rules, things can get nasty. text-transform: uppercase; letter-spacing: 1px; color: #fff; text-align: center; space within the page, effectively creating a block that's centered and responsive. we're clearing the left float value to none , setting the width of the image to fill the  How to make a div take the remaining height. > There are also other ways to archive this effect e.g. by pushing down the lower element by an floating upper element.

CSS- Div- Be Careful When You Size Your Divs, Originally meant as a simple tool to group page elements, the DIV tag gives It makes sense: both DIVs and tables can be nested, have HEIGHT and WIDTH DIVs is fixed at 75%, so the extra content just runs out of both into the white space below. They will fill up the container DIV and the height of both will be equal. There’s actually a really easy way to remove whitespace that’s both easy and semantic. It’s called a custom font with zero-width spaces. Then you just change the font on the container and voila. Here’s a download to the font I just cooked up in font-forge with the css @font-face declaration included.

CSS float property, Note: Absolutely positioned elements ignore the float property! Note: Elements Use float with a list of hyperlinks to create a horizontal menu: .header, .footer { Lesson 8: Borders, Backgrounds, and Floating Divs - HTML html - CSS Floating Divs At Variable Heights - Stack Overflow How to make two divs stay next to each

2 div boxes side by side with space - Get Started, I would like to get 2 DIVs to sit side by side each other inside a DIV. the div2 floating to the right, but when you start to make the browser large… yellow box to push the blue box the remaining pixels filling the whitespace. I would like to get 2 DIVs to sit side by side each other inside a DIV. I created a quick image to show what I mean. Right now i have the div2 floating to the right, but when you start to make the

Comments
  • But what If I don't know what element goes under the green element? I have more than just 3 elements and they could differ in height, so does float right still work then?
  • It should. Can you add an example
  • You solved my problem in the first place, but in my real situation its not the right solution, do you want to help?
  • Would love to help. But it will take 3 hours. Im on the move and not on my pc
  • Thanks I will contact u then if it still isnt solved