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

1
point

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 {
    background-color:#999;
    overflow: hidden;
}

read up on floats here:

http://complexspiral.com/publications/containing-floats/

and new ways of containing floats here:

http://www.tjkdesign.com/articles/clearing-floats_and_block-formatting_context.asp

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