javascript - Card Img Overlay,溢出卡体
问题描述
我有一个卡片页面。顶部有一个缩略图和一个叠加层。卡体必须在覆盖层之外,但会溢出到卡体上
检查演示
https://codepen.io/snarex/pen/NWKbgZM
这是我的卡片设计的样本
<div class="card shadow bg-white rounded">
<a href="#">
<img src="https://placeimg.com/640/360/any" class="card-img-top" alt="...">
<div class="card-img-overlay text-center d-flex">
<img src="http://wptf.com/wp-content/uploads/2014/05/play-button.png"
class="w-25 align-self-center mx-auto "
alt="">
</div>
</a>
<div class="card-body">
<h5 class="card-title">
<a href="#" class="text-info">*</a></h5>
</div>
解决方案
您应该将“位置:相对”添加到链接元素(),以便覆盖连接到它而不是更高的父级
<div class="card shadow bg-white rounded">
<a href="#" class = "position-relative">
<img src="https://placeimg.com/640/360/any" class="card-img-top" alt="...">
<div class="card-img-overlay text-center d-flex">
<img src="http://wptf.com/wp-content/uploads/2014/05/play-button.png"
class="w-25 align-self-center mx-auto "
alt="">
</div>
</a>
<div class="card-body">
<h5 class="card-title">
<a href="#" class="text-info">Hızlı olan kazansın: SEO’nun gizli kahramanı “Page Speed”</a></h5>
</div>
推荐阅读
- javascript - jQuery如何从焦点输入字段值中删除
- ios - tableView 单元格未显示单元格中的任何内容,但它正在控制台中打印内容
- ansible - ansible角色造成的模板错误如何解决
- excel - 如果活动单元格包含特定文本,则清除其内容
- heroku - 由于依赖私有仓库,无法在 Heroku 上部署 Elixir 应用程序
- groovy - 如何解组
FDE 这种类型的 XML 获取 Domain 的值 - php - 为什么 PHPMailer 花费太多时间来发送电子邮件,而且一旦发送电子邮件,我就会收到垃圾邮件
- c# - 如何显示从 influxdb 读取的数据?
- c# - 使用 EF 核心关系时,Linq 查询返回 null
- scala - 如何将 csv 文件作为 akka http 响应发送?