溢出:自动打破chrome和firefox中的布局

时间:2013-06-19 06:23:48

标签: css google-chrome firefox css-float

为什么overflow:auto; .pageContent打破了Chrome和Firefox中的布局?它在Safari中运行良好。我该怎么办呢?我添加了它,因此clear:both;上的h2只会清除内容,而不会清除整个.pageAttributes div。

Here是网站。

它似乎是导致它的菜单中的border-bottom .selected。但仍然不确定为什么。

更新 - 测试用例jsfiddle

我已尝试overflow: visible;,但这会打破h2

HTML

<div class="page">
    <div class="pageAttributes">
        .pageAttributes
    </div>
    <div class="pageMenu">
        <div class="button">View</div>
        <div class="button selected">Edit</div>
        <div class="button">Talk</div>
        <div class="search">Search:&nbsp;&nbsp;
            <input type="text" id="searchItem">
        </div>
    </div>
    <div class="pageContent">
        <h2>header</h2>
        .pageContent
        <div class="pageFooter"></div>
    </div>
</div>

CSS

html, body {
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
}

.page {
    width: 1010px;
    padding: 0 5px 0 5px;
    margin: 0 auto 30px auto;

}

.pageAttributes {
    float: left;
    width: 245px;
    height: 250px;
    margin-bottom: 20px;
    background-color: #ccc;
}

.pageMenu {
    clear: right;
    margin-left: 250px;
    height: 25px;
    margin-bottom: -1px;
    border-bottom: 1px solid #a7d7f9;
    padding-left: 1px;
    padding-right: 1px;
}

.pageMenu .button {
    float: left;
    margin-left: -1px;
    height: 24px;
    border-top: 1px solid #a7d7f9;
    border-left: 1px solid #a7d7f9;
    border-right: 1px solid #a7d7f9;
    padding-left: 15px;
    padding-right: 15px;
    text-align: center;
    line-height: 25px;
    font-family: sans-serif;
    font-size: 13px;
    cursor: pointer;
}

.pageMenu .button.selected {
    background-color: white;
    border-bottom: 1px solid white;
    cursor: default;
}

.pageMenu .search {
    float: right;
    margin-right: -1px;
    height: 24px;
    border-top: 1px solid #a7d7f9;
    border-left: 1px solid #a7d7f9;
    border-right: 1px solid #a7d7f9;
    padding-left: 15px;
    padding-right: 15px;
    text-align: center;
    line-height: 25px;
    font-family: sans-serif;
    font-size: 13px;
    cursor: default;
}

.pageContent {
    position: relative;
    border: 1px solid #a7d7f9;
    margin-bottom: 5px;
    padding: 5px;
    background-color: white;
    line-height: 1.5em;
    overflow: auto;
    clear: right;
    margin-left: 250px;
}

.pageContent h2 {
    margin-top: 25px;
    margin-bottom: 3px;
    font-size: 16px;
    border-bottom: 1px dotted #CCC;
    clear: both;
}

2 个答案:

答案 0 :(得分:1)

试试这个,

#articleSections{
    float: left;
}

并从overflow: auto;

中删除.pageContent

答案 1 :(得分:0)

对我来说,似乎是一个浮动的问题,我无法在.button(s)和搜索输入之间清楚。所以定位可能是这样的解决方案

小提琴http://jsfiddle.net/LNMH9/3/

<style type="text/css">
html, body {
    width: 100%;
    height: 100%;
    margin: 0px;
    padding: 0px;
}

.page {
    position:relative;

    width: 1010px;
    padding: 0 5px 0 5px;
    margin: 0 auto 30px auto;
}

.pageAttributes {
    position:absolute;
    left:0px;
    top:0px;
    width: 245px;
    height: 250px;
    margin-bottom: 20px;
    background-color: #ccc;
}

.pageMenu {

    margin-left: 250px;
    height: 25px;
    margin-bottom: -1px;
    border-bottom: 1px solid #a7d7f9;
    padding-left: 1px;
    padding-right: 1px;
}

.pageMenu .button {
    float: left;
    margin-left: -1px;
    height: 24px;
    border-top: 1px solid #a7d7f9;
    border-left: 1px solid #a7d7f9;
    border-right: 1px solid #a7d7f9;
    padding-left: 15px;
    padding-right: 15px;
    text-align: center;
    line-height: 25px;
    font-family: sans-serif;
    font-size: 13px;
    cursor: pointer;
}

.pageMenu .button.selected {
    background-color: white;
    border-bottom: 1px solid white;
    cursor: default;
}

.pageMenu .search {
    float: right;
    margin-right: -1px;
    height: 24px;
    border-top: 1px solid #a7d7f9;
    border-left: 1px solid #a7d7f9;
    border-right: 1px solid #a7d7f9;
    padding-left: 15px;
    padding-right: 15px;
    text-align: center;
    line-height: 25px;
    font-family: sans-serif;
    font-size: 13px;
    cursor: default;
}

.pageContent {
    position: absolute;
    width:748px;
    border: 1px solid #a7d7f9;
    margin-bottom: 5px;
    padding: 5px;
    background-color: white;
    line-height: 1.5em;
    overflow: auto;
    clear: right;
    margin-left: 250px;
}

.pageContent h2 {
    margin-top: 25px;
    margin-bottom: 3px;
    font-size: 16px;
    border-bottom: 1px dotted #CCC;
    clear: both;
}
</style>
<div class="page">
    <div class="pageAttributes">
        .pageAttributes
    </div>
    <div class="pageMenu">
        <div class="button">View</div>
        <div class="button selected">Edit</div>
        <div class="button">Talk</div>
        <div class="search">Search:&nbsp;&nbsp;
            <input type="text" id="searchItem" />
        </div>
        <div style="clear:both;"></div>
    </div>
    <div class="pageContent">
        <h2>header</h2>
        Lorem ipsum 
        <div class="pageFooter"></div>
    </div>
</div>