Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
623 views
in Technique[技术] by (71.8m points)

css - HTML canvas with scrollbar

I am drawing graphs on canvases which have large unequal widths. Is it possible for each canvas to have its own scrollbar? I tried to put all the canvases in one div and specify a max-width but it didn't work. Is it possible for all the canvases to be say 500px in visible width on the page and each has its scrollbar to view the entire width of the canvas.

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Specify the total width of the canvas then wrap it in a div. Set the div to overflow: scroll and give that the 500px width. You should then have scrollbars allowing you to scroll and see the hidden parts of the canvas. Repeat this for all of the canvases.

<div style="max-height: 256px;max-width:256px;overflow: scroll;">
          <canvas width="512px" height="512px"></canvas>
</div>   

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...