Overlay HTML5 canvas over image

前端 未结 2 717
Happy的楠姐
Happy的楠姐 2021-01-31 05:20

I want to have an image which is uploaded from my database and on top of it the exact same size in the same position is a HTML5 canvas.

Most of the solutions I have foun

2条回答
  •  醉话见心
    2021-01-31 05:58

    Possible duplicate.

    Depending on how many images are in the database, you could have a separate canvas id for each with the name of the image file (e.g. canvas #foo { background:url(foo.jpg) }). I would load this in a separate stylesheet. :)

    It would probably be easier to maintain a Javascript solution though if your database is dynamic. A few lines of javascript would be sufficient, instead of constantly updating a stylesheet with new names. Less error typo prone as well.

提交回复
热议问题