日期:2014-05-16  浏览次数:20593 次

div居中问题
<div id="div11">
        <div style="float:left;" id="div22">111</div>
        <div style="float:left;" id="div33">222</div>
    </div>

怎样使div33中文字对div11居中水平居中,不能使用固定宽度,只能使用css样式能居中吗

注意是要针对div11居中,不是div33内水平居中
div

------解决方案--------------------
能,
.button_all {
text-align: center;
}
参考:http://www.cnblogs.com/bisonjob/archive/2008/01/17/1042328.html
------解决方案--------------------
不用固定宽 就用 百分比
------解决方案--------------------
#div11
{
  vertical-align:middle;
}
------解决方案--------------------
既然想居中,为什么还要浮动
------解决方案--------------------

#div11{
  width:100%;
  background-color:blue;
}
#div33{
  width:100%;
  text-align: center;
  background-color:yellow;
}


看看是不是这效果