Search code examples
cssruby-on-rails-4fontsbootstrap-modaljquery-ui-selectmenu

Having trouble styling my Rails select menu


I’m using Rails 4.2.3. I want to change the font of a select menu but I’m having trouble doing it. I installed the “bootstrap-sass” gem and added this to my stylesheet …

select {
        font-family: 'Oxygen', sans-serif;
}

and then set up my select tag this way

<%= select_tag :state, options_for_select([["Select State", nil], *us_states]), {class: "form-control"} %>

but when my menu is rendered the options continue to have the normal font and not the one I specified. What else do I need to do to style my Rails select menu?


Solution

  • This should work for you:

    <%= select_tag :state, options_for_select([["Select State", nil], *us_states]), class: 'states form-control' %>
    

    You don't need to send it in a secondary hash.

    I'd also consider adding a more identifiable class name for example:

    .states {
        font-family: 'Oxygen', sans-serif;
    

    }