Bootstrap5下划线默认更改?
在 Bootstrap 4 中,我知道它将默认文本装饰设置为无。
但是使用 Bootstrap 5,如果我只是添加一个原始锚标记,它现在会同时显示蓝色文字和下划线。
我希望只在悬停时显示 undelrine。这是 Bootstrap 5 在发布中改变的东西吗?我找不到任何说明它的文件。
目前我使用:
a {
text-decoration: none;
color: inherit;
}
a:hover {
text-decoration: underline;
color: inherit
}
但这也会影响任何按钮作为链接,例如
<a href="{% url 'answer-create' question.id %}">Answer</a>
回答
是的,从 Bootstrap 5 alpha1 开始,迁移文档指出:
“链接默认带有下划线(不仅仅是悬停时),除非它们是特定组件的一部分”
你可以像这样创建一个特殊的类:
.text-underline-hover {
text-decoration: none;
}
.text-underline-hover:hover {
text-decoration: underline;
}
<a href="#">Link</a>
演示
或者,如果您希望它应用于除包含class=属性的锚点之外的所有锚点,请使用:
a:not([class]) {
text-decoration: none;
}
a:not([class]):hover {
text-decoration: underline;
}
这不会影响btn,只有没有的链接class会在悬停时加下划线。