Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正如您在此处看到的,您需要应用静态高度,#wrapper否则 div 将不包含其子级。(这是小提琴)这很合乎逻辑。但是,我希望我可以给#wrapper 一个自动高度,通过它可以包含多行相对定位的元素。
#wrapper
我想我可以在单个项目周围添加另一个包装器并将它们静态定位?但我宁愿不添加更多的 HTML。如果需要,可以使用 JS/jQuery 解决方案。
有一个浮动是您的孩子 DIV,因此您必须清除它parent并从中删除高度。像这样写:
parent
#wrapper { background-color: white; min-height: 360px; margin: 50px auto; overflow: hidden; padding: 10px; width: 1008px; }
检查这个http://jsfiddle.net/y5nYN/16/