twitter-bootstrap 引导程序将链接样式分配给非 <a> 元素

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22866902/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 20:25:53  来源:igfitidea点击:

bootstrap assign link style to non <a> element

classtwitter-bootstraphyperlinkstyles

提问by kekko12

Is there a way to assign the bootstrap link style to a non <a>element?

有没有办法将引导链接样式分配给非<a>元素?

I mean something like this:

我的意思是这样的:

<span class="link">Some text</span>

采纳答案by Rachel S

You can use the classes btn btn-link. These are Bootstrap link styles that usually are found on anchor tags or button tags but if you use it on any other text it will use those styles on your text. It may not yield the exact same results so your CSS may need to be tweaked.

您可以使用类btn btn-link。这些是通常在锚标签或按钮标签上找到的 Bootstrap 链接样式,但如果您在任何其他文本上使用它,它将在您的文本上使用这些样式。它可能不会产生完全相同的结果,因此您的 CSS 可能需要进行调整。

回答by Cichy

No. Non exists CSS class with link styles. If you open source code of Bootstrap you can find definition link styles for atag.

不。不存在带有链接样式的 CSS 类。如果你打开 Bootstrap 的源代码,你可以找到a标签的定义链接样式。

bootstrap/scss/_reboot.scss

引导程序/scss/_reboot.scss

//
// Links
//

a {
   color: $link-color;
   text-decoration: $link-decoration;
   background-color: transparent; // Remove the gray background on active links in IE 10.
   -webkit-text-decoration-skip: objects; // Remove gaps in links underline in iOS 8+ and Safari 8+.

   @include hover {
      color: $link-hover-color;
      text-decoration: $link-hover-decoration;
   }
}