twitter-bootstrap - 使用 Bootstrap 将两个按钮居中

标签 twitter-bootstrap twitter-bootstrap-3

我正在尝试使用 Bootstrap 将两个表单按钮居中,但我无法让它工作!

这是我的代码:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Form</title>

    <!-- Bootstrap -->
    <link href="static/fw/css/bootstrap.min.css" rel="stylesheet">
    <link href="static/fw/css/bootstrap-theme.min.css" rel="stylesheet">

    <!-- Custom styles -->
    <link href="static/code/style.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>


    <div class="container" role="main">

        <div  class="center-block">
            <button type="submit" class="btn btn-success">Save</button>
            <button type="submit" class="btn btn-danger">Cancel</button>
        </div>


    </div> <!-- /container -->

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="static/fw/js/bootstrap.min.js"></script>
    <script src="static/code/script.js"></script>
  </body>
</html>

最佳答案

将 .text-center 添加到包含按钮的 div 中。

http://jsbin.com/sosab/1/edit?html,output

关于twitter-bootstrap - 使用 Bootstrap 将两个按钮居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26076290/

相关文章:

css - 是否可以将 CSS 选择器中的重要属性值变为不重要的属性值?

html - 如何在 Bootstrap 中使列变大或变小?

css - Bootstrap img-circle css 类将我的图像调整为不同的比例

css - 移动网页布局 - 轮播式

javascript - Bootstrap 轮播控件没有响应

css - 在 twitter bootstrap 中使用什么来获取全屏元素?

html - ASP.NET 和 Bootstrap : input type ="text" with width:100% does not span the whole width of the div container

css - Bootstrap Pills 空间在顶部?

javascript - 从 AJAX 请求结果更新 Bootstrap 警报文本

javascript - 具有绝对位置的 div 中的弹出窗口位置