M
M
Marat Akhmetshin2015-03-29 17:13:38
JavaScript
Marat Akhmetshin, 2015-03-29 17:13:38

How to adjust the width and height of the canvas for the browser?

I'm just starting to explore the vast expanses of canvas and it's not clear how to make the canvas adapt to the browser. If I understand correctly, without specifying a specific size, you can make it "cross-sized".
Please provide an example if possible.
PS I know how to use Google. That's what I didn't find.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim Bogomazov, 2015-03-29
@bukrat

1
2

A
Alexander Shpak, 2015-03-29
@shpaker

If you do not specify the size, then by default it is like 150 by 100 pixels.
You need to resize yourself when the window resizes.

S
Stas Densis, 2015-03-29
@deenween

same as div. Try it as a percentage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question