html - Bootstrap4 Cards,在卡片图像上覆盖一个按钮?

标签 html css twitter-bootstrap bootstrap-4

我目前正在试验 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/

相关文章:

jquery - 阻止 bootstrap 3 在导航栏按钮的末端创建填充

css - 无法使用 Foundation CSS 创建新元素

html - 元素在平板电脑浏览器上显示不正确

javascript - 使用 html 和 php 生成密码

html - HTML5 离线应用程序中的文件上传

html - Div 不覆盖子项

css - Bootstrap 布局在宽屏显示器上表现得很奇怪

javascript - jquery 无法显示和隐藏元素

html - 子 div 宽度超过父 div 宽度

css - 我无法在 Bootstrap 元素中编辑我的 custom.css