我认为这是不可能的,但我不是CSS专家,所以我想我会检查.我有一个半透明的div绝对定位在图像上.到目前为止,这是好的,但我想强制我的半透明div尊重它和图像所包含的盒子.
<div class="parent">
<div class="title-bar"> /* prolly not important */
<h2>Title</h2>
</div>
<img src="whatever"/>
<div class="overlay">
A few lines of txt
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我想的越多,我认为我可能要求的就越多 - 我希望父母用img扩展,但是叠加被父母约束.可以这样做吗?