i want to build a site with a log in, Registration, ect forms. what im wondering is there a way to pass a variable into the css file some like width:20em; but instead of the 20 i want a variable that can change with each form so the felidset looks right?
Share
Several ways you could go about this, really, but I’d go with the following:
Give each form a special class or id (Rails will often auto-generate classes/ids on form tags – I find it annoying, but it might be convenient in your case), and then, in your stylesheets, you can use rules like:
Other methods would involve adding style information to every text input you create (set a @input_style variable in your action, use it (explicitly) where needed – seems like a lot of work compared to the above, though) or using JavaScript to add the styles after the page has loaded (prone to cause re-render flicker, though, and adding CSS with JS just feels tacky).
So basically, there are a bunch of ways to do this, but I’d recommend CSS and drill-down. Less typing for you, and the browsers take care of everything. Hope this helps!