div中的滚动条

问题描述 投票:0回答:3

我有一个div,里面有一张桌子。在此表中,您可以看到有一个图像标记。通过Javascript我设置图像src并显示。 我的问题是,如果图像很大,div必须滚动,但它不滚动。

<div style="position:absolute;top:30px;left:640px;overflow:auto;">
<table frame="box" width="600px" height="330px">
  <tr>
    <td><img id="graphId" style="display:none" src="" /></td>
  </tr>
</table>
</div>
html image html-table
3个回答
3
投票

在这种情况下,<img>的大小总是缩放到适合<td>

在这里,我将向您展示如何以正确的方式使用overflow

<div class="scroll">
    <div class="child"></div>
</div>
<style>
    .scroll{overflow:scroll;width:500px;height:500px;background:black}
    .child{width:1000px;height:1000px;background:yellow}
</style>

Demo on jsfiddle.


1
投票

在div样式属性中将overflow:auto;更改为overflow:scroll;

scroll的定义:

剪辑溢出,但添加了滚动条以查看其余内容


1
投票

尝试定义div的高度和宽度......

http://jsfiddle.net/qyFTt/2/

© www.soinside.com 2019 - 2024. All rights reserved.