I have multiple canvases layered over eachother, basically I'm making a paint app that has history and delete. The canvases are not the same width as the parent div.
I was banging my head on the desk trying to center my canvas within the div until I read this answer, which is pretty much the lowest voted question.
In short:
The above answers only work if your canvas is the same width as the container.
This works regardless:
#container {
margin: 0px auto;
text-align: center;
}
If I comment out text-align my canvases go off center.
Q: How does this make any sense and why does text-align have an effect on canvas elements?
There are some weird quirks about CSS that I've learned in similar ways and use quite often. I think understanding this will be another tool in the chest to use.