I am using twitter bootstrap and I have some code like this:
<%= link_to "Create", new_something_path %>
which renders the text in a light blue color, highlighting it as a link.
How would I reference that element to change it via css?
I am using twitter bootstrap and I have some code like this:
<%= link_to "Create", new_something_path %>
which renders the text in a light blue color, highlighting it as a link.
How would I reference that element to change it via css?
Give the link a class name
<%= link_to 'Create', new_something_path , :class => "newsomething"%>
add the following to your CSS.SCSS file
a.newsomething{
color: #000;
&:hover {
color: #000;
}
}
You can add a CSS class or id to a link_to
by setting it in the html_options
hash, which is the last parameter of the link_to
helper.
For example, using Ruby 1.9 hash syntax (convert to :key => 'value'
if using Ruby 1.8):
Just the CSS selector .new-something-class
:
<%= link_to "Create", new_something_path, class: 'new-something-class' %>
or for a link with with the CSS selectors #new-something-id
and .new-something-class
:
<%= link_to "Create", new_something_path, class: 'new-something-class', id: 'new-something-id' %>
You could then reference this element in your .css
file(s) as usual.
If you have twitter bootstrap installed:
<%= link_to 'Create', new_something_path , :class => "btn btn-primary some-class"%>
css
.some-class{
color: black;
....
}