我想div用CSS垂直居中.我不想要表或JavaScript,只需要纯CSS.我找到了一些解决方案,但所有这些解决方案都缺少Internet Explorer 6支持.
<body>
<div>Div to be aligned vertically</div>
</body>
Run Code Online (Sandbox Code Playgroud)
如何div在所有主流浏览器(包括Internet Explorer 6)中垂直居中?
有没有办法在主要父母的内部垂直或水平居中html元素?
我想将我的模态放在视口中间(中间)我试图添加一些css属性
.modal { position: fixed; top:50%; left:50%; }
Run Code Online (Sandbox Code Playgroud)
我正在使用这个例子http://jsfiddle.net/rniemeyer/Wjjnd/
我试过了
$("#MyModal").modal('show').css(
{
'margin-top': function () {
return -($(this).height() / 2);
},
'margin-left': function () {
return -($(this).width() / 2);
}
})
Run Code Online (Sandbox Code Playgroud) 我有一个只存在表单的页面,我希望将表单放在屏幕的中心.
<div class="container">
<div class="row justify-content-center align-items-center">
<form>
<div class="form-group">
<label for="formGroupExampleInput">Example label</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
</div>
<div class="form-group">
<label for="formGroupExampleInput2">Another label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input">
</div>
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
该justify-content-center对齐表格水平,但我无法弄清楚如何垂直对齐.我试过使用align-items-center和align-self-center,但它不起作用.
我错过了什么?
如何使用CSS 集中Bootstrap V4模式?