Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haml: How to set inline style for element in HAML

Here is my code:

<div class='some' style='position: absolute; left: 300; top: 300;'>..</div> 

It parses only style='position: absolute', and doesn't parse the other styles. How can I achieve this?

like image 328
ValeriiVasin Avatar asked Nov 11 '11 05:11

ValeriiVasin


People also ask

Which attribute is used to provide inline styles?

HTML style Attribute The style attribute specifies an inline style for an element. The style attribute will override any style set globally, e.g. styles specified in the <style> tag or in an external style sheet.

How do I write code in HAML?

In Haml, we write a tag by using the percent sign and then the name of the tag. This works for %strong , %div , %body , %html ; any tag you want. Then, after the name of the tag is = , which tells Haml to evaluate Ruby code to the right and then print out the return value as the contents of the tag.

What is HAML code?

Haml (HTML Abstraction Markup Language) is a templating system that is designed to avoid writing inline code in a web document and make the HTML cleaner. Haml gives the flexibility to have some dynamic content in HTML.


2 Answers

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;" } 
like image 115
dnch Avatar answered Sep 18 '22 18:09

dnch


No need to use %div:

.some{ style: 'position: absolute; left: 300px; top: 300px;' } 
like image 45
Incerteza Avatar answered Sep 20 '22 18:09

Incerteza