我有代碼:集裝箱垂直居中對齊考慮頁眉和頁腳
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
html, body {
height: 100%;
}
.container {
min-height: 200px;
max-height: 500px;
display: -ms-flexbox;
display: flex;
-ms-flex-pack: justify;
justify-content: space-between;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
box-sizing: border-box;
max-width: 1440px;
margin: auto;
height: 100%;
}
header, footer {
height: 150px;
background: #ccc;
}
footer {
position: absolute;
width: 100%;
height: 50px;
bottom: 0;
}
</style>
</head>
<body>
<header></header>
<div class="container">
content blah blah blah
</div>
<footer>
fsdfsdfsdfsdfsdffdsadsfasd
</footer>
</body>
</html>
如何我可以垂直居中對齊這個容器,考慮到頭部的高度和頁腳(位置:絕對和高度)。我想,我們可以用display來做什麼:flex,是怎麼做到的?
我用引導3格
例jsbin:http://jsbin.com/timatozuco/edit?html,output
但是,如果使用自舉3,我怎麼能實現此代碼? – DronaxD
好吧,現在這是完全不同的問題,你之前沒有提到過,但如果你使用Bootstrap,那麼這可能會幫助你。 https://stackoverflow.com/questions/15641142/bootstrap-fill-fluid-container-between-header-and-footer – Adeel
@DronaxD現在你添加Bootstrap 3在你的問題:) – Adeel