【发布时间】:2014-04-24 10:27:15
【问题描述】:
我有一些服务器端代码可以在 html <pre></pre> 标签中输出内容,我希望能够将它们放入带有滚动条的容器中。 (特别是表格单元格 - 宽度相等)。显然我想保留<pre> 标签空白格式。
HTML:
<table>
<tr>
<th>Col 1</th>
<th>Col 2</th>
</tr>
<tr>
<td><pre>
function thisIsATest(bla){
Testing 123456789 Testing 123456789 Testing 123456789
}
</pre></td>
<td><pre>
function thisIsATest(bla){
Testing 123456789 Testing 123456789 Testing 123456789
}
</pre></td>
</tr>
</table>
CSS:
table {
width: 100%;
border: 1px solid red;
}
td {
width: 50%;
overflow: scroll;
border: 1px solid blue;
}
(我正在 Firefox 中测试它)。我究竟做错了什么?谢谢
【问题讨论】:
-
你想达到什么目标?你的小提琴怎么了?
-
表格不适合窗口,我希望它完全可见,减少列宽。在整个页面的代码中,表格位于一个固定宽度的 div 中,并且表格右侧超出 div 宽度的部分被隐藏。这在您对 JSFiddle 的看法中不明显吗?我现在也在 IE11 中对其进行了测试,我得到了与 Firefox 相同的结果