Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:22:26+00:00 2026-05-25T12:22:26+00:00

How can I add an icon to a rails button with css? My request

  • 0

How can I add an icon to a rails button with css?

My request is both for <% button_to %> and <% f.submit %>

Thanks for helping

Hello @jdc I’ve finally found the trick, I did not use your method, but it was helpul to find my way.Thanks a lot man.So thi is How i proceed :

1°) Change the html.erb code from :

<%= f.submit %> 

to

<%= f.submit , :id => 'button' do -%>
<% end %>

2°) In the app/assets/stylesheets and put the following css code:

#button {
background-image: url(plus_8x8.png);
background-repeat:no-repeat;
display:block;
float:left;
margin:0 7px 0 0;
background-color:#f5f5f5;
border:1px solid #dedede;
border-top:1px solid #eee;
border-left:1px solid #eee;

font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
font-size:12px;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:#565656;
cursor:pointer;
padding:5px 10px 6px 7px;;  /* I put this here to move the text away on older IE junk */

}

Of course #button at the top of the css code is the :id name in <%= f.submit , :id => 'button' do -%> code in the html.erb file

I hope this will help you guys to style css button on rails 3 applications.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:22:27+00:00Added an answer on May 25, 2026 at 12:22 pm

    If I understand what you’re asking, you could try something like this:

    <% f.submit :html => { :class => 'imgbutton' } %>
    

    then in your css:

    background: url(someicon.gif);
    border: none;  /* If your icon IS the button */
    color: transparent;  /* If you don't want the button text to show up */
    *padding-left: 9999px;  /* I put this here to move the text away on older IE junk */
    

    Might not work for some really ancient browsers to do it with CSS though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i add notification icon on a button..I m able to add it
I know I can add a icon to the Resources.resx file of a project
On the iPhone, you can add a numbered badge to the application icon. On
Thanks to Max Gontar, I can put my notification icon in the status bar
Can please add a badge to a notification icon like it appear in this
I can add an icon to a menu item by adding an <icon> to
I want to add icon to the navigation bar present in my xcode project.Can
Is there a command line tool that can add an icon to an existing
How can I add an icon to QDialog, but not the icon on a
How can I add icon for my j2me application midlet? I am using eclipse.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.