默认的链路颜色为蓝色。 我如何删除html超链接标签< >的默认链接颜色?
当前回答
我在使用Bootstrap 4开发Rails 6应用程序时遇到了这个挑战。
我的挑战在于,我不希望这个样式覆盖应用程序中的默认链接样式。
所以我创建了一个CSS文件,叫做custom.css或custom.scss。
然后定义一个新的CSS规则,具有以下属性:
.remove_link_colour {
a, a:hover, a:focus, a:active {
color: inherit;
text-decoration: none;
}
}
然后,在需要覆盖默认链接样式的地方调用此规则。
<div class="product-card__buttons">
<button class="btn btn-success remove_link_colour" type="button"><%= link_to 'Edit', edit_product_path(product) %></button>
<button class="btn btn-danger remove_link_colour" type="button"><%= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } %></button>
</div>
这解决了覆盖默认链接样式的问题,并仅在我调用CSS规则的地方删除了按钮中的默认颜色、悬停、焦点和活动样式。
这是所有。
我希望这对你们有帮助
其他回答
我在使用Bootstrap 4开发Rails 6应用程序时遇到了这个挑战。
我的挑战在于,我不希望这个样式覆盖应用程序中的默认链接样式。
所以我创建了一个CSS文件,叫做custom.css或custom.scss。
然后定义一个新的CSS规则,具有以下属性:
.remove_link_colour {
a, a:hover, a:focus, a:active {
color: inherit;
text-decoration: none;
}
}
然后,在需要覆盖默认链接样式的地方调用此规则。
<div class="product-card__buttons">
<button class="btn btn-success remove_link_colour" type="button"><%= link_to 'Edit', edit_product_path(product) %></button>
<button class="btn btn-danger remove_link_colour" type="button"><%= link_to 'Destroy', product, method: :delete, data: { confirm: 'Are you sure?' } %></button>
</div>
这解决了覆盖默认链接样式的问题,并仅在我调用CSS规则的地方删除了按钮中的默认颜色、悬停、焦点和活动样式。
这是所有。
我希望这对你们有帮助
a:link{color:inherit;}
这是简单的一行,可以为你做所有的事情<3
.cancela,.cancela:link,.cancela:visited,.cancela:hover,.cancela:focus,.cancela:active{
color: inherit;
text-decoration: none;
}
我觉得有必要发布上面的类定义,很多关于SO的答案错过了一些状态
如果你不想看到浏览器提供的下划线和默认颜色,你可以把下面的代码放在main.css文件的顶部。如果你需要不同的颜色和装饰样式,你可以使用下面的代码片段轻松覆盖默认值。
a, a:hover, a:focus, a:active {
text-decoration: none;
color: inherit;
}
简单地添加到CSS中,
a {
color: inherit;
text-decoration: none;
}
就这样,完成了。
推荐文章
- 使伸缩项目正确浮动
- 如何取消最大高度?
- 形式内联内的形式水平在twitter bootstrap?
- 自定义元素在HTML5中有效吗?
- 如何选择在最后一个子元素之前的元素?
- 如何触发自动填充在谷歌Chrome?
- CSS变换,锯齿边缘在铬
- 创建圈div比使用图像更容易的方法?
- 强迫孩子服从父母的弯曲边界在CSS
- 为什么Chrome浏览器不正确地确定页面是在不同的语言,并提供翻译?
- 在CSS中@apply是什么?
- 在网页上用鼠标模拟震颤(例如帕金森病)?
- Bootstrap抛出Uncaught错误:Bootstrap的JavaScript需要jQuery
- 如何改变文本区域的边框颜色:焦点
- 我如何设置背景颜色为文本的宽度,而不是整个元素的宽度,使用CSS?