Html 跨度与 href 链接不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22982146/
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
Span with a href link not working
提问by user3185936
Working to put a href in a span class, but I cant get the href link to work.
努力将 href 放在 span 类中,但我无法使 href 链接起作用。
<a href="../../public/bassengweb/logout">Logg ut<span class="label label-danger"></span></a>
Also the label-danger wont show up.
标签危险也不会出现。
采纳答案by Albzi
Link to working span - Bootply
That's because of this line in the CSS:
那是因为 CSS 中的这一行:
.label:empty{
display:none;
}
If you write something between the span
tags, it will work.
如果你在span
标签之间写一些东西,它会起作用。
<a href="../../public/bassengweb/logout"><span class="label label-danger">Logg ut</span></a>
Although, it will look terrible with 'normal' bootstrap label when hovered, maybe do something like this:
虽然,在悬停时使用“正常”引导程序标签看起来会很糟糕,但可以执行以下操作:
<a href="../../public/bassengweb/logout">Logg ut</a><span class="label label-danger">Danger</span>
回答by jeugen
The <span>
with class label
should have content,
check the Boostrap's example Boostrap Component - LabelMaybe you should try to put an "x"
该<span>
带班label
应该有内容,检查自举的例子自举组件-标签也许你应该尝试把一个“x”
<a href="../../public/bassengweb/logout">Logg ut<span class="label label-danger">x</span></a>
or use glyphicons, maybe
或使用字形,也许
<a href="../../public/bassengweb/logout">Logg ut<span class="label label-danger"><span class="glyphicon glyphicon-circle-arrow-right"></span></span></a>
回答by Hugo
This is the best way! It works easy and clean.
这是最好的方法!它工作起来既简单又干净。
<span onclick="window.location.href='www.google.com';">text</span>
and then you can give it a class:hover
for the color
然后你可以给它一个class:hover
颜色
回答by Aleksandra Kuna
For label css use:
对于标签 css 使用:
class="label label-important"
it worked for me
它对我有用