简体   繁体   中英

Bootstrap 3 Button Groups - how to make them links?

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

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

You can use the classes in bootstrap to change the a tag.

<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

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

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM