Jump to content

How do you expand a floating div?


eiranix

Recommended Posts

I have 6 divs that I want sitting side by side and have their widths expand to fit the parent equally.

But then I also want the 6 divs to start stacking under each other when their minimum-width is reached...

 

Is there a way to do this with css?

Link to comment
Share on other sites

Give percentage widths to your <div> elements. 16% should be enough to have six per row. Give a min-width to the <div> elements and they'll start stacking when that width is reached.

Link to comment
Share on other sites

It will go reducing the amount of boxes per row as the window gets thinner. The will be a gap on the right side, but it would be smaller than the width of one box and in the best of cases the gap will hardly be noticeable.

That's about as much as you can get with CSS. Then there's @media queries so you can apply a different style to the boxes when the window gets too small.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...