<div id="container" style="float:left;">
<img src="{{ p.sizes.2.url }}" width="200" height="auto">
<div class="trans_caption" style="position:absolute;background-color:#cccccc;">
Picture Caption
</div>
</div>
如何将标题叠加在图片的顶部...但在底部对齐?另外,我希望标题宽度与容器相同。我试着做 width:100%,但是没有用...
最佳答案
是that你在找什么?
只需在您的主 div 中设置 position:relative
- 它将允许相对于主 div 定位内部 div,并将您的内部 div 中的 bottom:0
设置为把它放在底部。带有 float:left
和 width:100%
的小 hack,没有 float
width:100%
似乎没有才能正常工作。
关于javascript - 我如何在 CSS 中进行绝对定位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4180093/