100%宽度按钮组?

时间:2017-06-30 15:06:57

标签: html css twitter-bootstrap

使用bootstrap框架,如何在黄色面板中将按钮组设置为100%?

参见示例: https://jsfiddle.net/DTcHh/34406/

侧面不应有填充物。

<div class="container">
  <div class="row">
    <div class="col-md-8" style="background-color:pink; height: 500px">
      Content here
    </div>

    <div class="col-md-3" style="background-color:yellow; height: 500px">
      <div class="btn-group" role="group" aria-label="Basic example">
        <button type="button" class="btn btn-danger">Delete</button>
        <button type="button" class="btn btn-primary">Duplicate</button>
      </div>
    </div>
  </div>
</div>

2 个答案:

答案 0 :(得分:0)

检查这个小提琴。我用你想要的东西做了新的事。

https://jsfiddle.net/exuLo7f7/

<!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/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<style>

.col-md-3{
    margin:0px!important;
    padding:0px!important;
}
</style>
</head>
<body>

<div class="container">
  <h2>Justified Button Groups</h2>
  <div class="row">
  <div class="col-md-9" style="background-color:yellow;">dsaaaaaaaasadsadsadsadsadsadsadsadsadsadsadsadsadsadsadsad</div>
  <div class="col-md-3" style="background-color:black;">
  <div class="btn-group btn-group-justified">
    <div class="btn-group">
      <button type="button" class="btn btn-primary">Apple</button>
    </div>
    <div class="btn-group">
      <button type="button" class="btn btn-primary">Samsung</button>
    </div>
    <div class="btn-group">
      <button type="button" class="btn btn-primary">Sony</button>
    </div>
  </div>
  </div>
  </div>
</div>

</body>
</html>

答案 1 :(得分:0)

Bootstrap genuily在col- *类中添加15px填充。

如果你想摆脱这些填充,你需要强制它们。 我添加了这个类:

.no-padding {
  padding : 0 !important;
}

它给了these results

希望它有所帮助。