+ 11

How to make sure your code fits in every phone?

When writing JavaScript based codes(especially with canvas),how do I make my code fit into every phone.Like when you specify a width and height of 200 for an object,200 on an a small phone still looks the same as 200 on a tablet meaning it isn't based on the devices width/height.How do I solve this problem

7th Feb 2018, 6:34 PM
᠌᠌Code X
᠌᠌Code X - avatar
9 Respuestas
+ 8
I think we can use 100% //dunno if I am right or wrong (I am from non web)
7th Feb 2018, 7:10 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 5
not sure to be honest, but maybe you can use @media queries?
7th Feb 2018, 7:07 PM
Ice
Ice - avatar
+ 5
thnx @ice for correcting me looks like I've to gain some basic knowledge in Web languages too
7th Feb 2018, 8:05 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 5
Math it out. Try to yet the maximum aspect ratio such that the distribution of points is similar, but not distorted. Like, if your device is 200px by 365px, try to find another 40:73 ratio that maximises space in code playground, for example, in a 400px by 765px device, the dimension is 400px by 730px. Once you find the scale ratio, adjust your numbers accordingly.
8th Feb 2018, 11:03 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
@Saurabh that would work if he doesnt want 200x200px specifically
7th Feb 2018, 7:13 PM
Ice
Ice - avatar
+ 4
@Jay You could, but if your screen size is lets say 1920x1080, the element will be ~490px. If your screen size is 1280x720 it will be ~320px. See the difference?
7th Feb 2018, 8:02 PM
Ice
Ice - avatar
+ 4
you can check my code, i use % for fit screen. https://code.sololearn.com/Wn7Gkz968ccI/?ref=app hope it help.
8th Feb 2018, 11:36 PM
João Duarte
João Duarte - avatar
+ 3
That is what I think too
7th Feb 2018, 7:07 PM
Sad
Sad - avatar
+ 1
I’m not a web designer so I can’t teach it to you, but “@media query CSS” is what you need to google to get started. That’s the standard way to make sure web components stay the proper proportions when on different display sizes. They also work when resizing a browser on a desktop.
15th Mar 2018, 6:57 PM
Sean Patrick Franklin
Sean Patrick Franklin - avatar