Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap 映像未调整大小-引导4,Rails 5_Twitter Bootstrap_Ruby On Rails 5_Bootstrap 4_Twitter Bootstrap 4 - Fatal编程技术网

Twitter bootstrap 映像未调整大小-引导4,Rails 5

Twitter bootstrap 映像未调整大小-引导4,Rails 5,twitter-bootstrap,ruby-on-rails-5,bootstrap-4,twitter-bootstrap-4,Twitter Bootstrap,Ruby On Rails 5,Bootstrap 4,Twitter Bootstrap 4,这让我有点发疯。我正在使用bootstrap 4 class.img fluid,它应该会使图像响应父对象 我正在使用railsimage\u标记调用一个文件名路径,它是存储在我的postgres db中的一个字段。图像显示得很好,但在手机上查看时无法正确调整大小 使用标准html调用图像是否会有所不同?当然,我需要更改我的db字段,但这是可行的。您需要将类传递给映像本身,而不是包含它的div。img fluid类使用父级全宽: .img-fluid { max-width: 100%;

这让我有点发疯。我正在使用bootstrap 4 class
.img fluid
,它应该会使图像响应父对象

我正在使用rails
image\u标记
调用一个文件名路径,它是存储在我的postgres db中的一个字段。图像显示得很好,但在手机上查看时无法正确调整大小


使用标准html调用图像是否会有所不同?当然,我需要更改我的db字段,但这是可行的。

您需要将类传递给映像本身,而不是包含它的div。

img fluid类使用父级全宽:

.img-fluid {
  max-width: 100%;
  height: auto;
}
因此,您必须向图像本身添加
.img fluid
类:

<div>
  <%= image_tag(@coffeeshop.image_path, class: 'img-fluid') %>
</div>