开发者

Horizontal div positioning

CSS is cool, but it's also kind of tricky, right?

I have three burning questions for you CSS masters:

  1. If I have a div id="a" with all default properties (in terms of positioning and such), and I place another div id="b" inside of it and set its width and height in pixels and also set the float: left property, why doesn't div id="a" resize its height to accomodate div id="b"? Is it possible to achieve that?
  2. I have the following situation:

    Horizontal div positioning

    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 with float: 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?
  3. 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!


  1. 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 :(


  1. i think this is because div#b is a child element, so, div#a - being the parent - will not inherit properties from div#b.


  1. 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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜