【发布时间】:2016-10-03 08:06:57
【问题描述】:
我有一个在容器内显示 HTML 画布元素的页面。由于画布中显示的图像可能比我拥有的空间大得多,我强制容器的大小并使用它的溢出属性来滚动画布的内容。虽然容器和滚动条都正确显示,但画布会忽略它。
我的 HTML:
<div class="sidebar">
Some content
</div>
<div class="the_wrapper">
<div class="canvas_wrapper">
<canvas id="imageCanvas"></canvas>
</div>
<div class="another_element">
Some other content
</div>
</div>
这是 CSS:
.sidebar{
height: 100vh;
width: 20vw;
float: left;
}
.the_wrapper{
height: 100vh;
width: 80vw;
float: right;
}
.canvas_wrapper{
height: 60vh;
overflow: scroll;
}
.another_element{
height: 40vh;
}
但我得到的只是这个
【问题讨论】:
-
.canvas_wrapper和.canvasWrapper. 不匹配。 -
它可以在我的 chrome 上随心所欲地工作。可能是其他导致问题的原因。你能为此分享小提琴吗?
-
jsfiddle.net/tbhc2em4 是这样的吗?似乎可以在 firefox 和 chrome 中使用,只需更改
with以满足您的需求...(不作为答案发布,因为我不确定您是否要使用百分比) -
jsfiddle.net/MadanBhandari/un4L5tfz 工作正常,你可以在这里查看
-
在什么浏览器中?在firefox作品中