Html 尝试在 Bootstrap 3 中水平和垂直居中 div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22438166/
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
Trying to center div horizontally AND vertically in Bootstrap 3
提问by user3397240
Basically I'm trying to create a similar effect as shown on this url: http://www.mediafire.com/download/asgdi8i12sgi74x/geniets+byrde.txt
基本上我试图创建一个类似的效果,如这个网址所示:http: //www.mediafire.com/download/asgdi8i12sgi74x/geniets+byrde.txt
That is; I want to create a div (the box) and center it horizontally and vertically at all times. I'm using Bootstrap 3. It seems like a simply task but I haven't managed to do it.
那是; 我想创建一个 div(框)并始终将其水平和垂直居中。我正在使用 Bootstrap 3。这似乎是一项简单的任务,但我还没有设法做到。
Would love it you could help me out!
会喜欢它你可以帮助我!
回答by bingjie2680
This is general to CSS, not bootstrap3. and we normally do it like this:
这是 CSS 通用的,而不是 bootstrap3。我们通常这样做:
div {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
}