Sometimes, we want to add a scrollable canvas inside a div.
In this article, we’ll look at how to add a scrollable canvas inside a div.
How to add a scrollable canvas inside a div?
To add a scrollable canvas inside a div, we can make the div scrollable and put a canvas inside it.
For instance, we write:
<div style="width: 150px; overflow: auto; ">
<canvas width="200" style="border:1px solid #ff0000;"></canvas>
</div>
to add a div with the overflow CSS property set to auto
.
And then we add a canvas inside it with a red border.
Conclusion
To add a scrollable canvas inside a div, we can make the div scrollable and put a canvas inside it.