这是一个看起来比较简单的问题,但我仍然难以获得精确的输出。我需要将3个div对齐在页脚内的一个div中。我在Google上尝试过很多方法,之前也曾经成功过,但在页脚固定位置时它无法正常工作。
在这张图片中,白色容器div是页脚,红色是左侧,绿色是右侧,中间是中心。
以下是我的CSS代码:
我做错了什么?请解释一下。
在这张图片中,白色容器div是页脚,红色是左侧,绿色是右侧,中间是中心。
以下是我的CSS代码:
div .footer-container
{
height:53px;
width:100%;
position:fixed;
}
div .footer-container div .footer-left
{
background-color:#f00;
float:left;
width:33%;
height:31px;
}
div .footer-container div .footer-right
{
background-color:#0f0;
float:right;
width:33%;
height:31px;
}
div .footer-container div .footer-center
{
background-color:#f0f;
margin:0 auto;
height:31px;
width:33%;
}
这里是HTML:
<div data-role = "footer" class="footer-container">
<div>
<div class="footer-left"></div>
<div class="footer-right"></div>
<div class="footer-center"></div>
</div>
</div>
我做错了什么?请解释一下。