简体   繁体   中英

p5js insert canvas as table element

I'm trying to make a two-part project with p5 - which will contain a menu tab and the canvas in a table. But it appears that p5 auto-inserts the canvas into the document that it's imported to, thus appears below any html.

Is there any way to manually draw the canvas?

The p5 editor inserts the canvas at the end of the <body></body> tag before runtime, so the canvas can't be put into a table with p5's editor. It can be resolved outside of the editor by doing the following.

<table>
    <tr>
        <td>sample text</td>
        <td><canvas id="defaultCanvas" class="" width="400" height="540" style="width: 400px; height: 540px;"></canvas></td>
   </tr>
</table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM