这个问题的答案:
无解 ( 直接在CSS设置无解 不过有别的解决办法用) 替代方案是设置float/margin 或者js获取获取子元素高度, 或者直接给父元素设置高度最简单
下面是为什么无解 , 翻译在后面
Absolutely positioned elements are completely removed from the document flow, and thus their dimensions cannot alter the dimensions of their parents. If you really had to achieve this affect while keeping the children as position: absolute, you could do so with JavaScript by finding the height of the absolutely positioned children after they have rendered, and using that to set the height of the parent. Alternatively, just use float: left/float:right and margins to get the same positioning effect while keeping the children in the document flow, you can then use overflow: hidden on the parent (or any other clearfix technique) to cause its height to expand to that of its children.
绝对定位元素完全从文档流中删除,因此它们的维度不能改变它们的父元素的维度。 如果您确实需要在保持子元素的位置(absolute)的同时实现这种效果,那么您可以使用JavaScript来做到这一点,方法是在绝对位置的子元素呈现之后查找它们的高度,并使用它来设置父元素的高度。 或者,只需使用float: left/float:right和margin来获得相同的定位效果,同时将子元素保留在文档流中,然后可以使用overflow: hidden on the parent(或任何其他clearfix技术)来使其高度扩展到其子元素的高度。