twitter-bootstrap Bootstrap 3 按钮组 - 如何使它们链接?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28326454/
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 22:16:58  来源:igfitidea点击:

Bootstrap 3 Button Groups - how to make them links?

twitter-bootstraptwitter-bootstrap-3

提问by NathonJones

This seems really dumb to me, but what are the point of Bootstrap 3's button groups if you can't make them links?

这对我来说似乎很愚蠢,但是如果你不能让它们链接起来,Bootstrap 3 的按钮组有什么意义呢?

http://getbootstrap.com/components/#btn-groups

http://getbootstrap.com/components/#btn-groups

We've tried this:

我们试过这个:

<button type="button" class="btn btn-lg btn-success" href="add.php">
<span class="glyphicon glyphicon-plus"></span> Add
</button>

And...

和...

<button type="button" class="btn btn-lg btn-success">
<a href="add.php"><span class="glyphicon glyphicon-plus"></span> Add</a>
</button>

But neither work as links. What am I not understanding here? Thank you. NJ

但两者都不能作为链接。我在这里不明白什么?谢谢你。新泽西州

回答by haxtbh

You can use the classes in bootstrap to change the atag.

您可以使用引导程序中的类来更改a标签。

<div class="btn-group" role="group" aria-label="...">
  <a href="" class="btn btn-default">Left</a>
  <a href="" class="btn btn-default">Middle</a>
  <a href="" class="btn btn-default">Right</a>
</div>

<a href="add.php" class="btn btn-lg btn-success">
  <span class="glyphicon glyphicon-plus"></span> Add
</a

See the example here - http://www.bootply.com/v8anIQZU97

请参阅此处的示例 - http://www.bootply.com/v8anIQZU97

回答by Jason

HTML buttons don't have an href attribute. Instead try using anchor tags. Here's a Plnkrthat illustrates a button group using anchor tags to open search engines in a new window.

HTML 按钮没有 href 属性。而是尝试使用锚标记。这是一个Plnkr,它说明了使用锚标记在新窗口中打开搜索引擎的按钮组。

<div class="btn-group">
    <a class="btn btn-lg btn-success" href="http://www.google.com" target="_blank">Google</a>
    ....
</div>

回答by Ajay Joseph

Try this...

试试这个...

 <button type="button" class="btn btn-lg btn-success" onclick="location.href='@Url.Action("Action", "Controller")'">
 <span class="glyphicon glyphicon-plus"></span> Add
 </button>