Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
31
rated 0 times [  36] [ 5]  / answers: 1 / hits: 20681  / 9 Years ago, sat, january 2, 2016, 12:00:00

i want to know that, how to put the div tag generated with ajax dynamically onto the canvas.



I just create the div tage with ajax and append the generated divs to the another div tag on the jsp page. and i want to add main div on the canvas.



Thanks in advance.


More From » jquery

 Answers
16

canvas is an HTML element which can be used to draw graphics using scripting (usually JavaScript), so It's impossible to add an element inside canvas element, but you can play with css position to move the div inside canvas



<div class=container>
<canvas id=myCanvas width=200 height=100></canvas>
<div id=myDiv></div>
</div>


css:



.container{postion: relative;}
#myCanvas{background: red;}
#myDiv{height: 50px;width: 50px;background: blue;
position: absolute; top:10px;
}


see JSFIDLE


[#63869] Wednesday, December 30, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nikoguym

Total Points: 339
Total Questions: 106
Total Answers: 95

Location: Mali
Member since Sat, Feb 12, 2022
2 Years ago
;