将溢出设置为auto的居中div

时间:2011-06-28 15:41:13

标签: html css

我试图将几个DIV集中在一个包含DIV的内容中。基本上以整个网站为中心。在容器div中,我有2个div,称为嵌套和嵌套顶。我能够使nestedTop居中没问题,但我的嵌套div不会因为溢出而居中:auto; 。关于如何解决这个问题的任何想法?

这是css

    .container {
        height: 900px;
        width: 1400px;
        margin-right: auto;
        margin-left: auto;
        border-style: solid;
    }
    .nested {
        height: 210px;
        margin-right: auto;
        margin-left: auto;
        border-style: solid;
        width: 918px;
        overflow: auto;
    }
    .nestedTop {
        height: 520px;
        width: 918px;
        border-style: solid;
        margin-right: auto;
        margin-left: auto;
        margin-top:10px;
    }
    .dtree {
    font-size: 11px;
    color: #666;
    overflow:auto;
    width:200px;
    height: 600px;
    border-style : solid;
    border-color : black;
    white-space: nowrap;
    float: left;
    margin-top: 10px;
}
    .dtree img {
    border: 0px;
    vertical-align: middle;
}
    .dtree a {
    color: #333;
    text-decoration: none;
}
    .dtree a.node, .dtree a.nodeSel {
    white-space: nowrap;
    padding: 1px 2px 1px 2px;
}
    .dtree a.node:hover, .dtree a.nodeSel:hover {
    color: #333;
    text-decoration: underline;
}
    .dtree a.nodeSel {
    background-color: #c0d2ec;
}
    .dtree .clip {
    overflow: hidden;
}

我有一些javascript在这些div(dtree)的左侧生成一个菜单类型列表。第一个div正确居中,第二个/底部div不是,它是由于溢出:auto;

标记在这里

http://pastebin.com/AeaP2G7S

css在这里

http://pastebin.com/wv1Mb9jV http://pastebin.com/VpzLVLxR

我正在努力使其兼容IE7 +和firefox 3 +

由于

0 个答案:

没有答案