javascript - Web and physical units -
is there way tell/set, how many millimeters element has, works across various devices?
for example, create white window 100 x 100 mm, black 10 x 10 mm square in middle, have dimensions on desktop, tablet, print, ...
i don't mind use latest browser has use html/js/css.
ps: related: there way tell, how many millimeters screen has?
edit
in other words, problem using css units pt, mm, cm, ... not work browser vendors decided hardcode 96 dpi agents, according here. there 1 can real, physical, dimensions on web?
not really.
in theory can set lengths using mm
units, requires browser accurately handles dpi of display … , browsers tend assume fixed value instead of getting real one.
if worked, width in unit creating off-screen element of known physical dimensions, reading pixel dimensions using javascript , using ratio convert pixel dimensions of other element mm.
in practice, if need accurate measurements pretty limited drawing on screen , asking user measure ruler ratio.
alternatively, if can identify specific device in use (which user agent string may tell devices) , keep database of physical sizes of devices (so limited subset of phones , tablets , won't work if connected external display) use determine dimensions.
Comments
Post a Comment