【发布时间】:2019-11-24 00:36:46
【问题描述】:
查看光栅图像时,所有或多或少最近的 Mozilla 产品(例如:Firefox 和 SeaMonkey)将其转换为完整的 HTML文件,例如g.:
<html>
<head>
<meta name="viewport" content="width=device-width; height=device-height;">
<link rel="stylesheet" href="resource://gre/res/ImageDocument.css">
<link rel="stylesheet" href="resource://gre/res/TopLevelImageDocument.css">
<link rel="stylesheet" href="chrome://global/skin/media/TopLevelImageDocument.css">
<title>googlelogo_color_272x92dp.png (PNG Image, 544 × 184 pixels)</title>
</head>
<body>
<img src="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" alt="https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png">
</body>
</html>
默认CSS样式的内容可以在这里查看:
resource://gre/res/ImageDocument.cssresource://gre/res/TopLevelImageDocument.csschrome://global/skin/media/TopLevelImageDocument.css
问题在于,在 HiDPI 显示器上,低分辨率图像通常会被放大(例如,在 4k 显示器上,它们会放大 x1.5 倍)。 p>
我需要对生成的 HTML 应用哪些额外样式才能始终以原始大小显示图像(即 1:1)?
我正在寻找自定义userContent.css 或userChrome.css 的正确方法。
更多关于userChrome.css:
【问题讨论】:
-
你为什么不使用内联样式
style="width: 200px;height: 50px; -
@AshwinGeetD'Sa 因为我希望 CSS 是通用的,适合查看 any 图像。
-
这是仅在 Firefox 中的问题吗?如果没有,用 CSS 修复应该相对容易。
-
@jhpratt 我的问题完全是关于如何用纯 CSS 解决这个问题,但是以一种与大小无关的方式(即允许一劳永逸地修复它的方式)。
-
再深入研究一下,一定程度上绝对可以在 CSS 中实现,但需要详尽的 DPI / 像素比率列表。如果你愿意接受这样的解决方案,一点点 JS 就可以解决这个问题。
标签: html css firefox seamonkey