I’m not sure if div is the best thing to use but here goes.
I have 2 different types of canvases. Type 1 will be centered horizontally. Type 2 will be centered horizontally and vertically. I have 2 different snippets of code to make this happen listed below (someone else wrote this).
Sequence of my sketch:
- canvas1 displayed (type1; centered horizontally)
- canvas1 removed; canvas2 displayed (type2; centered vertically and horizontally)
- canvas2 removed; canvas3 displayed (type1; centered horizontally)
What changes do I make to my style.css to make this happen? Or maybe I should ask more generally, how do I make what I want to happen, happen?
Thanks!
Type1:
canvas {
padding: 0;
margin: auto;
display: block;
width: 800px;
}
Type2:
canvas {
padding: 0;
margin: auto;
display: block;
width: 800px;
height: 600px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
(Apparently the solution has something to do with this:
var myCanvas = createCanvas(winWidth, winHeight); myCanvas.parent("idnameofdiv");
Make sure you have to function in a script tag in the html as well. Note you do not add # in the .parent().
)