javascript - Always the same size of image on all screens -


I want the square image to always have the same size (including mobile, tablet) on any screen. So if I take the ruler and measure the image on any screen then it should be 5 mm for example. It should be in javascript.

I wonder if the image size depends only on the DPI of the screen or depends on the screen too? If I have detected the DPI of the screen in Javascript (and if necessary, resolution), to calculate the size of any formula (or some javascript function), to always get the same results?

In the end, am I image size in some units, what image is always the same?

I asked the question here because it is connected to Javascript, if you think that it is more suitable for any other platform please tell me. / P>

Thank you ...

If I understand correctly, There is no way to image a certain full physical shape. You can define a width with full units like inches, centimeters or millimeters, but the rendered result is different from one screen to another.

Each browser has internally set 1 inch = 96px , and all other units are calculated along with that base. Therefore only if the body has a physical pixel-size size of 25.4 / 96 = 0.26458 mm , then the element determining the width in 5 mm is really 5 mm.

But the full physical size is a pixel varies widely on a different screen and is not able to detect it by javascript.

Edit According to your comment: Yes This is possible on your own screen You can display an element with a width set to 200mm And with a ruler, measure the actual width on the screen in mm. 200 / Your_maping gives you a conversion factor.

If you want to set a width for a fixed value now, then you have to multiply that value with the factor.

Display the following file and measure the width of the red quadrate:

   Doctype html & gt; & Lt; Top & gt; & Lt; Style & gt; Div {Width: 200mm; Height: 200mm; Margins: 50px; Background-color: red;} & lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

The conversion factor is valid for all the full units you use.

Some user interactions allow you to check the user screen, such as ZEISS, the page linked to you by the user on the screen on a fixed width (for example credit card = 54 mm width) It has to be compared. Since the user here is fixed and the code measures, the calculation of the factor is in the opposite direction: conversion factor F = code_result / 54 .

Steps to get 0.5mm-higher accuracy.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -