[英]How to change bootstrap link_to color on navbar
How to change link_to color on navbar to make it look like this; 如何在导航栏上更改link_to的颜色,使其看起来像这样;
<a class='brand' href='#'>PROJECT_NAME</a>
so far i have 到目前为止,我有
.brand
= link_to "PROJECT_NAME", root_path
but its still blue:( 但它仍然是蓝色的:(
Here's what worked for me ( part of the code is from the rails tutorial by Michael Hartl ): 这对我有用( 部分代码来自Michael Hartl的rails教程 ):
<%= 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: 然后在我的custom.css.scss文件中:
li {
overflow: auto;
padding: 10px 0;
border-bottom: 1px solid $gray-lighter;
a:link {
&.delete {
color: red;
}
}
}
If you just want to add a class to link_to
element, you need to add it after comma. 如果只想将一个类添加到link_to
元素,则需要在逗号后添加它。
= 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. 但是,根据我与Bootstrap合作的经验,我认为它不会改变您的颜色。 So, you need to add !important
to your .brand
class in CSS file to overwrite default Bootstrap colors. 因此,您需要在CSS文件中的.brand
类中添加!important
,以覆盖默认的Bootstrap颜色。 Or you can hardcode it like this (to avoid !important
conditions): 或者,您可以像这样对它进行硬编码(以避免!important
条件):
.navbar .nav > li > a {
&.brand {
color: #color;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.