如何在 erb
文件中设置虚线内联 css 属性。比如这个
<%= image_tag "some_image.png", html: {width: "some_width", height: "some_height", margin:"some_margin"}%>
这工作正常但是当我设置
<%= image_tag "some_image.png", html: {width: "some_width", height: "some_height", margin-left:"some_margin_left"}%>
我明白了
syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
最佳答案
你有这个错误是因为带有破折号的符号文字(-
,比如 :margin-left
)不是有效的符号。
应该是:
:"margin-left" => "some_margin_left"
此外,此语法应该有效:
margin: {left: "some_margin_left"}
关于html - 在 erb 文件中设置虚线内联样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27900271/