Several browsers contain developer tools for debugging this kind of stuff. For example, in Chrome, you can right click on an element, say "Inspect Element," and then (once you've ensured you're focusing on the right element), expand the "Computed Style" section on the right. It'll show the computed background color, and if you expand it, it will show you which rules were used to compute the result (and it'll show striked-out text for rules that were overridden by other rules).
Sorry I can't say for sure what your problem is, but I'd seriously suggest using browser tools to debug this.
Edit (after ApochPiQ posted): He's got a point about floating elements. They can have issues because parent elements may not contain them like you'd expect. In order to make them contained like you expect, you have to implement a "clearfix" hack, a popular example of which is on this StackOverflow question. One common way this is done is by making a CSS class rule .clearfix { /* ...typically stuff like what's in the Stack Overflow question... */ } and then just specifying elements with class="clearfix" as necessary. You can also use Chrome's (or any other decent browser's) tools to show how the dimensions are calculated for an element, which might be useful too.