我該如何在中間水平/垂直設置一個div?垂直位於中間的位置div
這是到目前爲止我的代碼:
HTML
<div id="outer">
<div id="inner">
<div id="signin_header">
Sign in
</div>
</div>
</div>
CSS
html, body {
height: 100%;
}
html {
display: table;
margin: auto;
height: 100%;
}
body {
display: table-cell;
}
#outer {
width: 100%;
text-align: center;
height: 100%;
}
#inner {
display: inline-block;
background-color: rgb(245, 245, 245);
background-image: none;
background-origin: padding-box;
background-size: auto;
border-bottom-color: rgb(229, 229, 229);
border-bottom-style: solid;
border-bottom-width: 1px;
border-left-color: rgb(229, 229, 229);
border-left-style: solid;
border-left-width: 1px;
border-right-color: rgb(229, 229, 229);
border-right-style: solid;
border-right-width: 1px;
border-top-color: rgb(229, 229, 229);
border-top-style: solid;
border-top-width: 1px;
display: block;
font-family: 'segoe ui', arial, helvetica, sans-serif;
font-size: 13px;
width: 300px;
padding: 25px;
}
#signin_header {
color: rgb(34, 34, 34);
display: block;
font-family: 'segoe ui', arial, helvetica, sans-serif;
font-size: 16px;
font-weight: normal;
height: 16px;
line-height: 16px;
margin-top: 0px;
width: 283px;
text-align: left;
}
小提琴可以在這裏找到
我試圖居中實際DIV – methuselah 2013-03-07 17:45:48
權,即實現爲中心的DIV本身,其實它把它直接在中間,中心的水平和垂直。如果你想讓你的文本保持與div左邊對齊,你仍然可以保留它,我只是假定你想讓文本居中以及他的div居中。 – 2013-03-07 17:48:02