twitter-bootstrap - Bootstrap:在图片上添加按钮
问题描述
目前,我有以下代码来显示我的图片。
<section id="gallery" class="row no-gutters">
{% for image in images %}
<a class="col-12 col-sm-6 col-lg-3" href="{{ image.image.url }}">
<img src="{% get_image image.image.url 'event_gallery_medium' %}" class="w-100">
</a>
{% endfor %}
</section>
我现在尝试在右下角添加一个按钮,人们也可以点击它。按钮应该打开{{ image.image.url }}
。
我创建了按钮:
<span class="d-md-none btn btn-sm btn-white">
<span class="fas fa-expand mr-2"></span>
View Photos
</span>
但是我仍然很难将它“放在”图片上,所以它位于右下角。
解决方案
我稍微修改了你的代码,希望你喜欢。
.button_class {
position: absolute;
bottom: 0;
right: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<section id="gallery" class="row no-gutters">
<div class="col-12 col-sm-6 col-lg-3 position-relative" href="google.com">
<a href="https://google.com" class="d-block"><img src="https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" class="w-100"></a>
<a href="https://google.com" class="btn btn-info button_class">Button</a>
</div>
</section>
推荐阅读
- reactjs - 状态变量在 React Redux 中互相更新?
- typescript - 如何在打字稿中为具有受保护构造函数的类声明`new()=> T`类型?
- python - 字典的列表值在迭代期间进入无限深度
- google-chrome - 您如何在 Chrome 开发工具中查看通过 AJAX CORS 请求设置的 cookie?
- ios - Docusign iOS SDK 直接发送信封而不打开任何东西也不要求做签名
- flutter - 如何将 async 从第 1 页传递到第 2 页,并在第 2 页执行函数但在第 1 页显示结果?
- javascript - 如何使 YouTube Embed 保持一致?
- list - 将一些ListB作为项目放入ListA,然后清除ListB,ListA也消失了
- powershell - Powershell 脚本不通过任务计划程序运行
- parquet - 列不均匀的 Parquet 文件