[英]Overwrite hyperlink style in Rails
I use Bootstrap for my CSS style. 我使用Bootstrap作为我的CSS风格。 I would like to fake a link as button, so I need to turn off hover styling:
我想伪造一个链接作为按钮,所以我需要关闭悬停样式:
a:hover {
color: #00438a;
text-decoration: underline;
} }
How would I override hover properties in my html file (and not overwriting what has been defined in Bootstrap). 我如何覆盖我的html文件中的悬停属性(而不是覆盖在Bootstrap中定义的内容)。
Thank you. 谢谢。
Make the style for a specific id tag. 为特定的id标记创建样式。
So change: 所以改变:
a:hover {
color: #00438a;
text-decoration: underline;
}
to 至
a#some_id_tag_name:hover {
color: #00438a;
text-decoration: underline;
}
Or create a specific class that overrides if you want to reuse the style. 或者,如果要重用该样式,请创建一个覆盖的特定类。
a.some_class_tag_name:hover {
color: #00438a;
text-decoration: underline;
}
You can't actually "turn off" CSS styles, you can only explicitly set them to something else (the inherit
value being somewhat of an exception). 您实际上无法“关闭”CSS样式,您只能将它们显式设置为其他东西(
inherit
值有点异常)。 Anyways, in your case: 无论如何,在你的情况下:
class
to your link class
Something like: 就像是:
.my-class:hover {
color: {YOUR_COLOR};
text-decoration: none;
}
You could also use inline style and !important
if you really, really have to: 你也可以使用内联样式和
!important
如果你真的,真的必须:
<a style="text-decoration:none !important"></a>
Avoid the second method whenever possible (ie almost always). 尽可能避免使用第二种方法(即几乎总是)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.