这让我有点发疯。我正在使用 bootstrap 4 类.img-fluid
,它应该使图像响应父级;https://v4-alpha.getbootstrap.com/content/images/
<div class="img-fluid"><%= image_tag(@coffeeshop.image_path) %></div>
我正在使用 railsimage_tag
调用文件名路径,该路径是存储在我的 postgres 数据库中的字段。图像显示得很好,但在移动设备上查看时我无法正确调整大小。
使用标准 html 调用图像会<img src="" />
有所不同吗?我当然需要更改我的 db 字段,但这是可行的。
本.img-fluid
类使用父母全宽:
.img-fluid {
max-width: 100%;
height: auto;
}
所以你必须为.img-fluid
图像本身添加类:
<div>
<%= image_tag(@coffeeshop.image_path, class: 'img-fluid') %>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句