I am trying to resize a CSS Canvas, and it is controlled with this Javascript currently.
I'm not best at Javascript : but is there a way to get the screenwidth and then just use that data rather than a less than and else.
So say screen size is 390x500. Can I not just get the screen.width and say -5 from it. Make it that size? So 390x500 would be '385'.
screenwidth = screen.width;
if (screenwidth < 400) {
canvas.width = 375;
canvas.height = 200;
} else {
canvas.width = 500;
canvas.height = 300;
}
Sorry, I didn't clarify. This is for sizing a signature pad. Messing with the CSS or HTML mucks everything. The sizing is handled within a large Javascript with coordinates etc...
Answer is: canvas.width = screen.width - 5;
Thx, don't know why I didn't see that was what I should have tried.
canvas.width = screen.width - 5?<canvas>? That's HTML.canvas { width:calc(100% - 5px); }, to get your result. No JavaScript needed.