这是一个常见的问题,但我仍然没有找到任何解决方案,我的问题。绝对定位的孩子和父母的高度是0
.parent
是一个滑块,.child
是图像。 我需要通过.child
高度(这是一个绝对定位元素)到.parent
。
.parent
有0px
高度。有任何想法吗?
在此先感谢。
<div class="parent">
<img class="child"></div>
</div>
.child {
position: absolute; //It must be absolute , because slider works with this
width: 100%;
top: 0;
left: 0;
right: 0;
}
你知道的图像尺寸或宽高比? –
你可不可以添加另一个''这是'相对'但没有'可见度'?这将使隐藏的图像占用空间。 – Chris
Javascript。但在滑块上设置高度并让孩子相应地适应......而不是相反。 –