<div class = "x" style="width:100%;">
<div class = "y" style="width:50%;float:left;">
<div class = "z" style="width:100%;">
</div>
</div>
<div class = "yy" style="width:50%;float:right;">
<div class = "zz" style="width:100%;">
</div>
</div>
</div>
类“z”/“zz”的div的宽度是否可以单独通过css设置为类“x”的div的宽度?
更新
解决方案在这里link (使用下面给出的答案)
最佳答案
这样做的唯一方法是将父 x 设置为相对位置,将 z div 设置为绝对位置
.x{
position: relative;
}
.z{
position: absolute ;
top:0;
left:0;
width:100%;
}
关于html - 将 div 的宽度设置为父级的父级宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34603686/