I'm trying to center two form buttons with Bootstrap but I can't get it to work!
here is my code:
<!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>
You need to add your row and col classes, also use text center
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="text-center">
<button type="submit" class="btn btn-success">Save</button>
<button type="submit" class="btn btn-danger">Cancel</button>
</div>
</div>
</div>
</div>
Add .text-center to the div containing the buttons.
http://jsbin.com/sosab/1/edit?html,output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With