我有一個紅色的div在一個固定的位置:頂部和底部是固定的。溢出Firefox和IE9 +
該div包含一個表格,其中一個單元格包含一個可滾動的div,以便內容不能溢出紅色div。
它看起來像這樣在Chrome:
但在Firefox中,內容的增加和溢出了紅盒子:
這裏是我的HTML:
<div id=a>
<div id=b>
<table id=c border=1>
<tr><th height=20 width=20>
<input type=button id=but value="Fill cell">
</th><th>A</th></tr>
<tr><th>dataname</th>
<td><div id=val class=scrollable>cell content</div></td>
</tr>
</table>
</div>
</div>
和CSS:
#a {
position:fixed; top:20px; left:20px; bottom:50px;width:200px;
background:red;
}
#b { height:100%; }
#c { width:100%; height:100%; }
.scrollable {
width:100%; height:100%;
overflow-y:auto;
}
下面是爲測試一個小提琴:http://jsfiddle.net/xusqc/
我建議你在提交答案之前測試的FF你的建議。
我該如何解決我的代碼在Firefox和IE9 +上我現在在Chrome上的行爲?
請注意,表中第一行的高度可能會在我的應用程序中動態更改。如果我的數據表有更多的行和單元格,解決方案必須適用。
'overflow:scroll'? – 2013-02-14 15:30:23
@queueoverflow它不起作用,我不希望滾動條在不需要時出現。 – 2013-02-14 15:31:01
在td中使用div不是一個好習慣,爲什麼不把id和class傳遞給div的父td?只是一個建議 – Toping 2013-02-14 16:16:32