I have two canvas elements, "canvas1", and "canvas2", inside of the div, "container". I seek to have these canvas elements displayed in the basic display: block;
format like they usually are auto formatted to, but when trying to center the div or the elements individually it always produces wacky results.
The canvas, "canvas3" has the CSS code working correctly to center it, but when applied to the div, the canvas elements within it do not move.
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Position</title>
</head>
<body>
<div id="container">Hello
<canvas id="canvas1"></canvas>
<canvas id="canvas2"></canvas>
</div>
<canvas id="canvas3"></canvas>
<style>
#container {
margin-left: auto;
margin-right: auto;
}
canvas {
height: 150px;
width: 150px;
border: 2px solid black;
display: block;
}
#canvas1 {
background-color: khaki;
}
#canvas2 {
background-color: springgreen;
}
#canvas3 {
background-color: navajowhite;
margin: auto;
right: 0;
left: 0;
top: 0;
bottom: 0;
}
</style>
</body>
</html>
Note: When running snippet, make sure you view full page.
The method used to achieve this doesn't need to include anything but the 2 canvas elements using the block display attribute, or another method that produces the same look. The attempt shown above has the canvas elements within a div, but I'm not sure if that is the best method to achieving my goals. Any help would be greatly appreciated.