dragonfly
dragonfly

Reputation: 13

Background not visible due to positioning

The background color of <ol> list is not displayed properly. This problem started after I floated label left and input right. How to fix this. The expected result is:

enter image description here

Here is my result: http://fiddle.jshell.net/WZ3nM/1/

Similarly I've problem with the div .wrapper. The shadow should be way below the content and there should be a white color background beneath <div class=.col-2>.

Upvotes: 1

Views: 133

Answers (4)

detaylor
detaylor

Reputation: 7280

As others have suggested you can clear the floated content - although this will add another element. You can also add

li{overflow:auto;}

which will prevent the list from collapsing. In IE6 you will also need the rule

li{height:1px;}

http://fiddle.jshell.net/WZ3nM/9/. This method does not require a clearing element.

Upvotes: 0

ebrandell
ebrandell

Reputation: 432

I modified your code and added a third <li> with the following style:

clear:both;

Your float was taking elements out of the document flow and this the background color didn't know where to end.

Hope that helps.

Upvotes: 0

samccone
samccone

Reputation: 10926

http://fiddle.jshell.net/WZ3nM/5/

Whenever you float things you must clear them at the end so that it can calculate the height properly

Upvotes: 1

Starx
Starx

Reputation: 78971

You need to clear the float, before you close your <ol>

Check it out here.

Upvotes: 1

Related Questions