Ruby on rails 如何在RubyonRails中设置图像标记的样式
我有一个图像标签,如下所示:Ruby on rails 如何在RubyonRails中设置图像标记的样式,ruby-on-rails,Ruby On Rails,我有一个图像标签,如下所示: <%= image_tag @user.photo.url(:large) %> 如何在CSS中为图像的一侧设置边框颜色?将生成什么html?将类或id添加到图像标签: <%= image_tag @user.photo.url(:large), :class => "style_image" %> 通过使用“样式”选项: “边框:1px纯红”%> 有关更多信息,请查看API 您还可以提供内联样式 <%= ima
<%= image_tag @user.photo.url(:large) %>
如何在CSS中为图像的一侧设置边框颜色?将生成什么html?将类或id添加到图像标签:
<%= image_tag @user.photo.url(:large), :class => "style_image" %>
通过使用“样式”选项:
“边框:1px纯红”%>
有关更多信息,请查看API 您还可以提供内联样式
<%= image_tag @user.photo.url(:large), :style => "float :left;border 1px solid #00000;" %>
“浮动:左;边框1px实心”#00000;”%>
尝试一下….对于在谷歌上遇到此问题的其他人。 如果您以不同的方式使用图像标记,您仍然可以向其添加css类,但这只是不同的语法。有时您需要使用外部服务器。(在Heroku上部署?=>Amazon s3)
这是一种简单的方法
<%= image_tag("example.png", :style => 'border-right: 1px solid #000;')%>
“右边框:1px实心#000;”)百分比>
在较新版本的Rails中,有一种“更好”的方法:
类似于
<%= image_tag @user.photo.url(:large), :style => "float :left;border 1px solid #00000;" %>
<%= image_tag("https://s3-us-west-2.amazonaws.com/mybucketname/user_photo.png", class: "style_image") %>
<%= image_tag("example.png", :style => 'border-right: 1px solid #000;')%>
<%= image_tag('filename_in_public_folder', alt: 'Description', style: 'display: block; margin: auto; width: 40%;')%>