How do you add more than one css class to an using image_tag?


Tags: css,ruby-on-rails

Problem :

How do you add more than one css class to an <img> using image_tag?

Using image_tag("image.png", :class => "class1, class2") seems not to work



Solution :

Don't separate the classes using a comma, separate them using a space...

image_tag("image.png", :class => "class1 class2")

Note: You cannot use a space inside a class name...separate them using _ or -, if you use space than class 1 class 2 will be like 4 classes in which all are invalid.


    CSS Howto..

    How can I get a jquery css container to pop up letting the user know data was successfully entered?

    How to remove white border from blur background image

    jquery carousel how to have a gradient on start and ending slides

    How to override content css property to not to use it on IE8?

    How can I make the left div expand and the right div have constant width?

    How to set style of active page number in ASP.NET GridView Pager?

    how to set word break in table th or td, when column and table-layout auto using CSS

    How to set CSS rule for a DIV in a LI of class UL?

    How can I apply CSS Mixins with native Javascript?

    How to use a variable for a path with Stylus?

    How to set css class to div area of ckeditor

    How to include this basic html (CSS, JavaScript) template into a php file?

    How to make a header bar fold over the webpage css

    How to create embossed borders in HTML, CSS? [closed]

    How * tag can be used in CSS?

    How to make jQuery show() stay on page

    How to make the divider between two tbody elements moveable

    jquery hide and show for printing

    How to add a tooltip for just the background image of an input field with HTML and CSS

    CSS frustration: How to center floating images of different widths inside LI tags?

    HTML/CSS - How to set text (e.g. 'Quote of the Day') to change automatically on page load/reload?

    How to get the first ClassB inside ClassA?

    HTML/CSS How to prevent highlighting text from spanning entire width of page in google chrome

    How do I make this sprite behave how I want?

    How to get the CSS attributes from a control located by XPath using Selenium IDE

    How do I center images inside a list?

    How do you work on your HTML and CSS in PLay! + intellij idea? [closed]

    How to place the text in the top right corner and not show buttons when printing

    CSS How to target element without a tag

    android - How to build complex views that stretch?