我目前正在试验 Bootstrap4,但我对图像有疑问。基本上我想要实现的是:
Bootstrap4 Card with top right button on image
我想在右上角的图像上叠加“三点”按钮。该按钮将充当下拉菜单,其中包含一些选项,例如编辑、共享等...制作没有按钮的卡片的代码是:
<div class="card" style="width: 20rem;">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-block">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some quick example text to build on the card
title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
我试过用 div 标签封闭 card-img-top 和一个按钮,但图像移出了边界。实现这一目标的任何提示?谢谢!
最佳答案
要么将图像用作背景图像并为其添加高度。或者给三点按钮加上position absolute,定位在top: 5px;右:5px。
关于html - Bootstrap4 Cards,在卡片图像上覆盖一个按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44142207/