I am currently developing an app allowing users to draw shapes top of an image.
I am using canvas with background-image
set to url("uploaded image_url")
.
I am having trouble getting canvas size fitted to background image size and to the viewport size at once.
Consider the following snipper - a lot of the lower image is cropped:
.drawer-area {
width: 90%;
background-image: url("https://i.picsum.photos/id/430/200/300.jpg?hmac=souGSmvwQ6KlJgthGYBGSWB22Y7MpK5xlgLYwvtbXzg");
background-size: cover;
}
<canvas class="drawer-area"></canvas>
Note, I don't know the size of the image beforehand. I am using background-size: cover
and width: 90%
, but it doesn't do the trick. Any advice?