• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Help centreing html5 canvas

Joined
Sep 15, 2009
Messages
2,076 (0.36/day)
System Name Omen
Processor i7-4710HQ
Cooling Dual fan/heatpipe
Memory 16GB
Video Card(s) 4GB GTX 860M
Storage 256GB PCIE SSD/256GB PNY UHS-1 SD Card
Display(s) 15.6' 1080P
Case Aluminium
Audio Device(s) Onboard
Power Supply Brick
Software Win 10
Don't know what youve done in the file because im at work so can't open it but here is how i performed the same thing.

Code:
canvas {
    padding-left: 0;
    padding-right: 0;
    padding-top:25px;
    margin-left: auto;
    margin-right: auto;
    display: block;
    width: 1050px;
}

Don't know if that will work or be of any help, i tried so many different methods that people posted on the net and that was the only one to work.
 
display block & margin auto + a width is how things get centered

also it looks nicer to use shortform, the numbers will be top right bottom left

so for example, if you wanted a top margin, centered horizontally, it would look like margin: 25px auto 0px auto;

but in this case just do margin: auto;
 
Back
Top