答案 0 :(得分:1)
尝试使用col-md-offset- *,这可能会对你有所帮助
<!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>
</head>
<body>
<form runat="server">
<div class="container">
<div class="row">
<div class="col-md-offset-3 col-sm-offset-3 col-xs-offset-3 col-md-6 col-sm-6 col-xs-6 ">
<div class="panel panel-primary">
<div class="panel-heading text-center">
<h3 class="panel-title">
<span class="glyphicon glyphicon-bookmark"></span> Quick Shortcuts</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="text-center">
<a href="#" class="btn btn-danger btn-block" role="button"><span class="glyphicon glyphicon-list-alt"></span> <br/>Apps</a>
<a href="#" class="btn btn-warning btn-block" role="button"><span class="glyphicon glyphicon-bookmark"></span> <br/>Bookmarks</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-signal"></span> <br/>Reports</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-comment"></span> <br/>Comments</a>
<a href="#" class="btn btn-success btn-block" role="button"><span class="glyphicon glyphicon-user"></span> <br/>Users</a>
<a href="#" class="btn btn-info btn-block" role="button"><span class="glyphicon glyphicon-file"></span> <br/>Notes</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-picture"></span> <br/>Photos</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-tag"></span> <br/>Tags</a>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
答案 1 :(得分:0)
您的代码中缺少结束标记。
要将mx-auto
添加到您的列中,如下所示:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<form runat="server">
<div class="container">
<div class="row">
<div class="col-md-6 mx-auto">
<div class="panel panel-primary">
<div class="panel-heading text-center">
<h3 class="panel-title">
<span class="glyphicon glyphicon-bookmark"></span> Quick Shortcuts</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="text-center">
<a href="#" class="btn btn-danger btn-block" role="button"><span class="glyphicon glyphicon-list-alt"></span> <br/>Apps</a>
<a href="#" class="btn btn-warning btn-block" role="button"><span class="glyphicon glyphicon-bookmark"></span> <br/>Bookmarks</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-signal"></span> <br/>Reports</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-comment"></span> <br/>Comments</a>
<a href="#" class="btn btn-success btn-block" role="button"><span class="glyphicon glyphicon-user"></span> <br/>Users</a>
<a href="#" class="btn btn-info btn-block" role="button"><span class="glyphicon glyphicon-file"></span> <br/>Notes</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-picture"></span> <br/>Photos</a>
<a href="#" class="btn btn-primary btn-block" role="button"><span class="glyphicon glyphicon-tag"></span> <br/>Tags</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
&#13;
P.S。您似乎使用的是Bootstrap 3,但您的标签表示Bootstrap 4。