集装箱分公司以外的浮动分公司

时间:2019-06-16 05:54:18

标签: css css-float

我正在尝试在主容器div中获取我的2个菜单和信息框。当我这样做时,它看起来像这样。 enter image description here

问题是当我使用float:left时,它们全部都放在了容器中,但是盒子一直浮动到最左端而不是居中。保证金对浮动的容器没有影响。我也尝试了不使用float并使用overflow:hidden,并且效果相同。

我在做什么错?为什么我的内部容器不会留在红色容器内。

这是我的容器代码:

#Wrapper {
    border: 10px solid #F00;
    display: block;
    height: auto;
    clear: both;
    margin-left: auto;
    margin-right: auto;
    width: 1024px;
}
#SidebarLeft {
    border: 1px black solid;    
    clear: left;
    float: left;
    width: 175px;
}
#SidebarRight {
    border: 1px black solid;
    clear: right;
    float: right;
    width: 175px;
}
.Info {
    background-color: #CCC; 
    border: 1px black solid;
    display: inline-block;
    float: left;
    font-family: Verdana, Geneva, sans-serif;
    font-size: 12px;
    margin-left: 9px;
    margin-right: 9px;
    padding: 5px;
    text-align:justify;
    width: 640px;
}

两个侧边菜单都处于浮动状态,但中间框没有。如果我将其浮动,则所有3个框都将落在Red框之外。我现在很困惑。

0 个答案:

没有答案
相关问题