Screen resolution | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Screen resolution

How can I make my web page compatible to all screen resolutions?

26th Apr 2018, 1:53 PM
B00350
B00350 - avatar
6 Answers
+ 7
Mike Choy wOW great answer!
26th Apr 2018, 10:43 PM
niteOwLTwO
niteOwLTwO - avatar
+ 3
Resolution: TheĀ resolutionĀ CSSĀ @mediaĀ media feature can be used to apply styles based on the pixel density of the output device. Syntax TheĀ resolutionĀ feature is specified as aĀ <resolution>Ā value representing the pixel density of the output device.Ā ItĀ is a range feature, meaning that you can also use the prefixedĀ min-resolutionĀ andĀ max-resolutionĀ variants to query minimum and maximum values, respectively. Example HTML: <p>This is a test of your device's pixel density.</p> CSS: /* Exact resolution */ @media (resolution: 150dpi) { p { color: red; } } /* Minimum resolution */ @media (min-resolution: 72dpi) { p { font-size: 1.5em; } } /* Maximum resolution */ @media (max-resolution: 300dpi) { p { background: yellow; } }
26th Apr 2018, 2:04 PM
Murad Ibrahim
Murad Ibrahim - avatar
26th Apr 2018, 4:51 PM
Mike Choy
Mike Choy - avatar
+ 2
in css use the percent: example p{height: 30 %} because if you do that, the paragraph will be forever the 30% of the page
26th Apr 2018, 1:59 PM
Etabeta1šŸ‡®šŸ‡¹
Etabeta1šŸ‡®šŸ‡¹ - avatar
0
Thanks. And if I use percent for the body tag in CSS?
26th Apr 2018, 2:02 PM
B00350
B00350 - avatar
0
It's working, but when I set the minimum resolution for example too small. My web page will not working on mobile phones.
26th Apr 2018, 2:12 PM
B00350
B00350 - avatar