twitter-bootstrap 如何在 Bootstrap 4 中将锚点设置为按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45542773/
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
How to style an anchor as a button in Bootstrap 4?
提问by Vadim Peretokin
When I use a button, it looks like this in Bootstrap 4:
当我使用按钮时,它在 Bootstrap 4 中看起来像这样:
<button type="button" class="btn btn-primary" target="_blank">Download</button>
<button type="button" class="btn btn-primary" target="_blank">Download</button>
When I use an anchor instead with the buttons styling, it looks like this:
当我使用锚点代替按钮样式时,它看起来像这样:
<a type="button" class="btn btn-primary" target="_blank">Download</a>
<a type="button" class="btn btn-primary" target="_blank">Download</a>
How can I get my anchor to look like a flat button?
我怎样才能让我的锚看起来像一个扁平的按钮?
采纳答案by xaid
First of all remove type="button"from <a>. You need to update css for and write custom css for <a>tag.
首先type="button"从<a>. 您需要更新 css 并为<a>标签编写自定义 css 。
a.btn {border-radius: .25rem; border: 1px solid transparent; padding: .5rem 1rem; color: #fff; }
a.btn:hover { border-radius: .25rem; }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-primary" target="_blank">Download</button>
<a class="btn btn-primary" target="_blank" href="#">Download</a>


