How to set inline style for element in HAML

后端 未结 5 798
执念已碎
执念已碎 2021-02-02 05:06

Here is my code:

..

It parses only style=\'posit

相关标签:
5条回答
  • 2021-02-02 05:44

    It would have been handy if you'd posted the HAML you're using, but this is how it's done:

    %div.some{ :style => "position: absolute; left: 300px; top: 300px;" }
    
    0 讨论(0)
  • 2021-02-02 05:45

    Requested a hash special case at: https://github.com/haml/haml/issues/787 to allow us to write:

    %div{ style: { display: "none", width: "50px" } }
    

    much like is possible for class: ["class1", "class2"].

    0 讨论(0)
  • 2021-02-02 06:01

    Another approach in addition to the hash one by Dan Cheail is such:

    %div.some(style='position: absolute; left: 300; top: 300;')
    
    0 讨论(0)
  • 2021-02-02 06:02

    No need to use %div:

    .some{ style: 'position: absolute; left: 300px; top: 300px;' }
    
    0 讨论(0)
  • 2021-02-02 06:09

    If you are looking inline css for image :

    <%= image_tag( 'image_name.png', style: 'height: 25px; width: 200px; position: absolute' ) %>
    
    0 讨论(0)
提交回复
热议问题