tom 5

I'm relatively new to CSS so apologies if this is a really basic...

alt text

I've floated the buttons right and placed them inside a div. I've then set a colored background to the div.

Why doesn't the div expand to fit the buttons?

Here's a link to the html / css

(p.s. I couldn't figure out how to insert the code in this post directly as it wasn't being escaped properly?!)

1 answer


floated elements will sit outside their container unless you tell the container to enclose them (shrink-wrap) you can float the container (the FNE method) or use overflow: hidden; which would be best for you in this instance.

#toolbar {
    overflow: hidden;

read up on floats here:

and new ways of containing floats here:

Answered over 9 years ago by Tony Crockford
  • You're my hero! tom over 9 years ago
  • would that mean this is the 'best answer'? :) Tony Crockford over 9 years ago