image_tag('batman.png' size:'100%xauto')
大小 100% x Auto 被忽略,因为它不遵循 Rails API 中概述的约定。
有没有办法在不需要全局/特定 css 类的情况下在 Rails 中做到这一点?
最佳答案
size 分布在“x”上,并在两侧找到数字。结帐 the code
您可以为 image_tag 使用 'style' 选项。
更新:
您可以使用带有样式的图像标签,如下所示
= image_tag 'image_url', style: 'height:100%;width:auto;'
关于ruby-on-rails - Rails image_tag 宽度属性使用百分比/自动值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30693728/