vb.net 在页面中央制作一个面板表单
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20118759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
make a panel form in the center of the page
提问by Abie Giordano
so I was trying to create a form panel with Twitter Bootstrap into the center of the page, and hopefully even when the browser is resizing, it still be at the center, here'swhat I tried on jsfiddle, the problem is I can't seem to make it center, anyone had ideas? the full code is in below
所以我试图用 Twitter Bootstrap 创建一个表单面板到页面的中心,希望即使浏览器调整大小,它仍然在中心, 这是我在 jsfiddle 上尝试的,问题是我看不到为了使它成为中心,有人有想法吗?完整代码在下面
<div class="container">
<div class="row">
<div class="panel panel-default">
<div class="panel-body">
<legend>User Login</legend>
<form role="form">
<div class="form-group">
<label for="inputEmail">
Username</label>
<input id="inputEmail" type="text" class="form-control" placeholder="ex: John.Doe"
required="" />
</div>
<div class="form-group">
<label for="inputPassword">
Password</label>
<input id="inputPassword" type="password" class="form-control" placeholder="*******"
required="" />
</div>
<div class="checkbox">
<label>
<input id="chkRememberMe" type="checkbox" />
Remember Me
</label>
</div>
<button id="btnSubmit" type="submit" class="btn navbar-custom">
Submit</button>
</form>
</div>
</div>
</div>
</div>
the preview:

预览:

回答by Ashish Charan
Please replace
请更换
<div class="panel panel-default">
with this
有了这个
<div class="panel panel-default" style="max-width:400px;margin-left:auto; margin-right:auto;">
回答by Teppic
You can also use columns to size and center your panel, for example:
您还可以使用列来调整面板的大小和居中,例如:
<div class="container">
<div class="row">
<div class="col-md-offset-3 col-md-6">
<div class="panel panel-default">
<div class="panel-body">
<legend>User Login</legend>
<form role="form">
<div class="form-group">
<label for="inputEmail">Username</label>
<input id="inputEmail" type="text" class="form-control" placeholder="ex: John.Doe" required="" />
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input id="inputPassword" type="password" class="form-control" placeholder="*******" required="" />
</div>
<div class="checkbox">
<label>
<input id="chkRememberMe" type="checkbox" />
Remember Me
</label>
</div>
<button id="btnSubmit" type="submit" class="btn navbar-custom">Submit</button>
</form>
</div>
</div>
</div>
</div>
</div>
回答by user3016621
Try setting the margins in the div's style attribute:
尝试在 div 的 style 属性中设置边距:
style="margin-left:auto;margin-right:auto;"
Hope it works...
希望它有效...

