Drawing over an image using Raphael.js

試著忘記壹切 提交于 2020-01-10 14:37:12

问题


Can I put a Raphael.js canvas over an IMG element? What should I do make this layout work?


回答1:


Simply position the Raphaël canvas over the top of the image element using normal CSS techniques:

#wrapper {
    position: relative;
    padding: 0;
    outline: 1px solid #999;
}
#wrapper img {
    position: absolute;
    top: 0;
    left: 0;
}
#canvas {
    position: absolute;
    top: 0;
    left: 0;
}

Then nest your elements like this:

<div id="wrapper">
    <img src="myimage.jpg">
    <div id="canvas">  
    </div>
</div>

Here's a full example.




回答2:


z-index:2 or some high number for the raphael "paper" div (aka your raphael canvas... which you refer to by:

var paper = Raphael('somediv', 100, 400)

so just go to your css and at #somediv make sure you put it's z-index lower and then put your text div's z-index higher...



来源:https://stackoverflow.com/questions/3407333/drawing-over-an-image-using-raphael-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!