<div style="position: relative">
<img src="http://52.66.90.164/Show_barcode">
<div stule="position: absolute;top:100%;">
<p style="float:left;width: 33.33%">Hello world my name is Rushabh Shah.</p>
<p style="float:left;width: 33.33%">Hello world my name is Rushabh Shah.</p>
<p style="float:left;width: 33.33%">Hello world my name is Rushabh Shah.</p>
</div>
</div>
我想要 33.33% 的图像而不是父 div。我怎样才能做到这一点?图片宽度和高度是动态的。
最佳答案
只有在图像容器 div
上设置 float: left;
才有可能,如下所示:
<div style="position:relative; float:left;">
<img src="http://via.placeholder.com/650x150">
<div style="position:absolute; width:100%; left:0; top:100%;">
<p style="float:left;width: 33.33%">Hello world my name is Rushabh Shah.</p>
<p style="float:left;width: 33.33%">Hello world my name is Rushabh Shah.</p>
<p style="float:left;width: 33.33%">Hello world my name is Rushabh Shah.</p>
</div>
</div>
关于javascript - css div宽度根据图像宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50384258/