1

How to change link_to color on navbar to make it look like this;

<a class='brand' href='#'>PROJECT_NAME</a>

so far i have

.brand
   = link_to "PROJECT_NAME", root_path

but its still blue:(

fuskie
  • 85
  • 6

2 Answers2

1

Here's what worked for me (part of the code is from the rails tutorial by Michael Hartl):

<%= link_to "delete user", user, method: :delete,
      data: {confirm: "Are you sure you want to delete this user?" }, class: 'delete' %>

Then in my custom.css.scss file I have:

li {
    overflow: auto;
    padding: 10px 0;
    border-bottom: 1px solid $gray-lighter;
    a:link {
      &.delete {
        color: red;
      }
    }
  }
Kyle Krzeski
  • 6,183
  • 6
  • 41
  • 52
0

If you just want to add a class to link_to element, you need to add it after comma.

= link_to "PROJECT_NAME", root_path, class: 'brand'

But of my experience of working with Bootstrap, I think, that it won't change your color. So, you need to add !important to your .brand class in CSS file to overwrite default Bootstrap colors. Or you can hardcode it like this (to avoid !important conditions):

.navbar .nav > li > a {
  &.brand {
    color: #color;
  }
}
Peter Tretyakov
  • 3,380
  • 6
  • 38
  • 54
  • it didn't help. i can change font-size in brand class using !important but it doesnt work with color property, dont know why;/ – fuskie Jun 09 '13 at 15:15
  • I've just checked on my bootstrap project. Everything works fine. Does your `brand` belongs to `a` element, not `li`? Can you show your CSS with `brand` and its parent elements? And output of your browser with this link? – Peter Tretyakov Jun 09 '13 at 19:04