I am working on one application in which I want to make font size which is independent of screen resolution and screen size. The font size should be same in all resolutions and all screen sizes. How to do it with javascript and css?
I think Pixel per point is hardware related thing so i am not sure javascript and css have access of it.
I tried many alternatives but couldn't find exact solution.
To change your display in Windows, select Start > Settings > Ease of Access > Display. To make only the text on your screen larger, adjust the slider under Make text bigger. To make everything larger, including images and apps, choose an option from the drop-down menu under Make everything bigger.
Modern computer monitors / screens leave the factory with the screen resolution set at 1024 x 768 pixels or even higher. This is to give the maximum effect for graphics, particularly for playing computer games. However this has the effect of making the text size, and icon size smaller in general use.
Click on the “Start Menu,” then “Settings.” Choose “Ease of Access.” In the “Make everything bigger” section, click on “Change the size of apps and text on other displays.” Even though it says “other displays,” the option you choose applies to all screens/monitors.
To set your computer's displayed font size to default: Browse to: Start>Control Panel>Appearance and Personalization>Display. Click Smaller - 100% (default). Click Apply.
You can use points (pt
), which are based on 1/72 of an inch. This is a unit that traditionally comes from printing. Now, it depends on whether or not the device is configured properly, whether or not this size will be the same from monitor to monitor. It often isn't, but some devices are aware of their physical screen sizes. You can also use inches in
, centimeters cm
, and millimeters mm
.
Use this size, in conjunction with ems
, which are relative sizes. That way, the whole site can scale up and down as needed.
body {
font-size: 12pt;
}
h1 {
font-size: 2em;
}
p {
font-size: 1.1em;
}
There is no good, universal solution. In my opinion, you should just consider that it's not possible. This article was recently published, and suggests a (long-term) solution to that problem. It's long-term because it depends on multiple players (hardware and software manufacturers) to work out.
To quote the author:
It’s ridiculous that we can send robots to Mars yet it’s still virtually impossible to render a glyph on a web page and say with confidence: “If you measure this glyph on your screen with a ruler, it will be exactly 10 millimeters wide.”
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With