CSS is cool, but it's also kind of tricky, right?
I have three burning questions for you CSS masters:
- If I have a div
id="a"
with all default properties (in terms of positioning and such), and I place another divid="b"
inside of it and set its width and height in pixels and also set thefloat: left
property, why doesn't divid="a"
resize its height to accomodate divid="b"
? Is it possible to achieve that? - I have the following situation:
Purple div is just a regular div (
padding: 10px
), white things are the items of the horizontally oriented ul list (again placed in its own div withfloat: left
) and the green div is yet another div (display: inline-block
) with the<p>A company</p>
tag placed inside. The question is how do I make the div containing the list bottom align to the green div? - And the last question, related to t开发者_如何学运维he previous situation: How do I make the green div stretch from the white div on the left to the end of the purple div on the right?
Thank you to everyone who understood my questions and is willing to share the answers!
- Read this: http://www.smashingmagazine.com/2009/10/19/the-mystery-of-css-float-property/
Sorry, but I don't understand the second and third question :(
- i think this is because div#b is a child element, so, div#a - being the parent - will not inherit properties from div#b.
- Here's an explanation: http://www.fiveminuteargument.com/float-container. In short, floated elements are expected to be able to span - for example - multiple paragraphs, so it wouldn't make sense for them to cause their containers to expand.
精彩评论