如何对齐表单元素中心

时间:2017-02-22 07:22:00

标签: html css twitter-bootstrap

please see this picture!

我试图调整形式元素'到中心。

这是我试过的。

1.我使用.form-inline {margin:0 auto;} 2。在表格类中添加了文本中心=" form-inline"

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<div class="jumbotron">
<form class="form-inline">
<label class="sr-only" for="email">Email address</label>
<div class="input-group">
<div class="input-group-addon">@</div>
<input type="email" class="form-control" id="email" placeholder="Your email"> </div>
<button type="submit" class="btn btn-primary">Sign up</button>
</form>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="library/tether-master/dist/js/tether.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<script>
< /html>

你能帮我找一个解决方案吗?

2 个答案:

答案 0 :(得分:2)

尝试以下CSS:

.form-inline {
     margin: 0 auto;
     display: table;
}

答案 1 :(得分:0)

如果您使用的是twitter-bootstrap,为什么不使用bootstrap元素?抵消列

getbootstrap。com / CSS /#网格抵消

这是Bootstrap解决方案及其响应!

&#13;
&#13;
0.0
&#13;
&#13;
&#13;