如何将image_tag与bootstrap类一起使用:“img-responsive”? 第11章

我问这个问题的原因是为了帮助我解决一个非常烦人的语法错误。 我正在使用第11章,所以我可以在我的新网站上用图像构建一个博客部分,当我尝试添加类时,一切都在分开:“img-responsive”到这一行。

 

我只是无法弄清楚添加类的正确语法:“img-responsive”。

图像上传很好,但它突破了col-md-6容器,并显示打破页面布局的完整图像,因此除了我尝试添加类时,它们都在本地工作:括号中的“img-responsive”或括号,我试图崩溃应用程序的每一种方式,所以我卡住了。 我已经四处寻找其他解决方案了,我发现了一个可以与carrierwave配合使用的gem……

响应图像gem

但这似乎就像用大锤敲打坚果一样,到目前为止我已经想到的所有其他问题,但这真的很烦人。 我无法找到适合响应图像的载波resize的任何东西,当然我可以使用img-responsive类?

关心肖恩

尝试将标签放在括号内

 <%=image_tag(image_article.picture.url, class: "img-responsive") if image_article.picture?%> 

试试这..我为我工作..代替xyz.png,在Assets文件夹中添加图像名称。

<%= image_tag(“xyz.png”,类:“img-responsive img-thumbnail img-circle”)%>

Bootstrap 4使用class:’img-fluid’而不是’img-responsive’

尝试:

 <%= image_tag image_article.picture.url, class: 'img-fluid' if image_article.picture? %> 

你试过这个:

 <%= image_tag image_article.picture.url, class: "img-responsive" if image_article.picture? %>