【发布时间】:2014-10-10 19:06:58
【问题描述】:
我试图在页面底部居中放置一个 div,但没有运气。我在网上搜索过,但在尝试应用他们的解决方案时却一无所获。
那里的任何人都可能有解决方案吗?见以下代码:
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script></script>
<style type="text/css">
body {
background-color: aqua;
height:100%;
min-height:100%;
}
.centerDiv {
display: table;
width:90%;
margin:0 auto;
height:100%;
min-height:100%;
text-align: center;
}
.box {
display: inline-block;
width: 100px;
height:100px;
border: 3px solid #fff;
}
</style>
</head>
<body>
<div class="centerDiv">
<div class="box box1" style="background-color:#585858;"> </div>
<div class="box box2" style="background-color:#118C4E;"> </div>
<div class="box box3" style="background-color:#C1E1A6;"> </div>
<div class="box box4" style="background-color:#FF9009;"> </div>
</div>
</body>
</html>
【问题讨论】:
-
1.不要使用
display: table;。 2. 您是指停留在页面底部的页脚吗?