Bootstrap 4.1按钮之间的空格

时间:2018-12-07 13:08:40

标签: button bootstrap-4 spacing

我试图弄清楚如何使用Bootstrap 4.1中的margin等空格分隔下面显示的按钮。我在包装器div上尝试了 btn-toolbar ,但也用 btn-group 包裹了每个按钮,但无法获得结果。

是否有一种简单的方法可以通过Bootstrap 4.1进行处理,或者我应该使用某些CSS?

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
</head>
<body>
  
<div class="container">
  <button _ngcontent-c5="" class="btn btn-success" type="submit">Add</button><button _ngcontent-c5="" class="btn btn-danger" type="button">Delete</button><button _ngcontent-c5="" class="btn btn-primary" type="button">Clear</button> 
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:3)

使用spacing utils。例如mr-1表示右边距1个间隔单位...

<div class="container">
  <button _class="btn btn-success mr-1" type="submit">Add</button><button class="btn btn-danger mr-1" type="button">Delete</button><button  class="btn btn-primary" type="button">Clear</button> 
</div>

相关:How do I use the Spacing Utility Classes on Bootstrap 4