如何在 bootstrap 类中使用 image_tag:“img-responsive";?第11章 [英] How to use the image_tag with bootstrap class: "img-responsive" ? Chapter 11
问题描述
我问这个问题的原因是为了帮助我解决一个非常烦人的语法错误.我正在使用第 11 章,所以我可以在我的新网站上用图像构建一个博客部分,除了我尝试在这一行添加 class: "img-responsive" 之外,一切正常.
The reason I’m asking the question is to get some help me with a really annoying syntax error. I'm using chapter 11 so I can build a blog section on my new site with images, everything is working apart from when i try to add class: "img-responsive" to this line.
<%= image_tag image_article.picture.url if image_article.picture? %>
我只是想不出添加类的正确语法:img-responsive".
I just can't figure out the correct syntax to add class: "img-responsive".
图像上传正常,但它脱离了 col-md-6 容器,并显示了破坏页面布局的完整图像,所以除了我尝试添加类时,它都在本地工作:img-responsive"在括号或括号中,我尝试的每一种方式都会使应用程序崩溃,所以我被卡住了.我四处寻找其他解决方案,我发现了一个适用于载波的 gem ...
The image is uploading fine but it breaks out of the col-md-6 container, and displays the full image breaking the page-layout, so it's all working locally apart from when I try to add class: "img-responsive" in parentheses or brackets, every way I try crashes the app, so I’m stuck. I've looked around for other solutions, i've found a gem that works with carrierwave ...
但这似乎就像用大锤敲碎坚果,到目前为止我已经解决了所有其他问题,但这真的很烦人.我找不到任何适合响应式图像的载波调整大小,我当然可以使用 img-responsive 类吗?
but this seems to be like using a sledgehammer to crack a nut, so far all the other problems i've had i've figured out, but this is really annoying. I can't find anything with carrierwave resizing that fits the bill for responsive images, surely i can use the img-responsive class?
问候肖恩
推荐答案
尽量把标签放在括号内
<%=image_tag(image_article.picture.url, class: "img-responsive") if image_article.picture?%>
这篇关于如何在 bootstrap 类中使用 image_tag:“img-responsive";?第11章的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!