TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

In CSS, “px” is not an angular measurement and it is not non-linear

345 点作者 jipumarino超过 11 年前

11 条评论

jahewson超过 11 年前
This article makes some good points but it&#x27;s missing a bit of history. The reference pixel is defined at 96dpi because that&#x27;s how Windows treated the screen in the days before high-dpi support. Mac OS treated the screen as 72dpi in the pre-retina days but most early websites were built to look correct on Windows. That&#x27;s why MS Office fonts look too small on the Mac to this day: 26% too small to be precise.<p>This explains why CSS uses a human-eye based definition of the reference pixel: to escape from the Windows and Mac OS idea of the having a &quot;logical dpi&quot; which differs from the screen&#x27;s actual, physical dpi. Indeed, Windows and Mac OS can not agree on what an &quot;inch&quot; is!<p>Go ahead and open up Word and Pages on the Mac and create a 12pt font - see the difference! This is the mess that the CSS reference pixel fixes.
评论 #6674051 未加载
darkhorn超过 11 年前
Can we abandon these inches and miles please?!
评论 #6669836 未加载
twelvechairs超过 11 年前
whilst the detachment of &#x27;px&#x27; and screen pixels is a no brainer in the modern world with its proliferation of pixel densities and viewing distances on different devices, the CSS standard could probably do a better job of explaining this.
评论 #6670293 未加载
评论 #6671175 未加载
ivanhoe超过 11 年前
Don&#x27;t really understand why is it such a big deal how browsers internally define the size of pixels, do they use dpi or angles (it would be more correct to say trigonometry)? It is an interesting fact that I&#x27;ve never before really gave a thought, but complete irrelevant to anyone but guys building the browser rendering engines. And still now you have people calling for new &quot;better&quot; units and what not? Why? What am I missing?
评论 #6670325 未加载
评论 #6670944 未加载
kickingvegas超过 11 年前
Here we go again. IMHO, we need a new unit to unambiguously describe angular measure. But also we need to start demanding resolution independent units that map to real world measurements as well.<p><a href="https://news.ycombinator.com/item?id=4236429" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4236429</a>
评论 #6669690 未加载
评论 #6671192 未加载
评论 #6671045 未加载
Kiro超过 11 年前
So should you just use em for everything?
评论 #6669148 未加载
评论 #6669136 未加载
评论 #6670060 未加载
rahul286超过 11 年前
We spent time juggling between em and px before but from few months we are using &quot;rem&quot; unit.<p>It works nicely as we are also using font-icons everywhere.<p>See: <a href="http://snook.ca/archives/html_and_css/font-size-with-rem" rel="nofollow">http:&#x2F;&#x2F;snook.ca&#x2F;archives&#x2F;html_and_css&#x2F;font-size-with-rem</a>
intangible超过 11 年前
Most of our problems would go away if mm was actually a mm and the dpi differences were taken care of by the OS + screen + browser... Ugh. Sounds like we&#x27;re stuck with inconsistency for various dpi devices for many years to come still :-&#x2F;
Hellenion超过 11 年前
The reason the standards don&#x27;t speak of 2D euclidean geometry is because they (Very sensibly, IMO) left room for yet unknown devices that might not fit that description but still are able to conform.
JacobIrwin超过 11 年前
Key takeaway: &quot;1px is always equal to 0.75pt.&quot;
jmillikin超过 11 年前
This response is taking issue with the words used, rather than the underlying claim of the original article. In fact, this response contains a whole section and a diagram which are effectively supporting evidence for the original!<p>The most important thing to take away from the original is that the css unit &quot;px&quot; has no relationship to the actual size of a pixel on the screen, and all the physical units (inch, cm, pt) are defined in terms of the csspixel. So marking a button as &quot;width: 1cm&quot; will almost never render something over 1cm of the screen geometry.<p>Incidentally, this is why designers like device models with only a few geometries, such as the iPhone. They can do the math themselves to work out how many iphone-pixels are in a cm, and write their styles accordingly.
评论 #6669522 未加载
评论 #6669501 未加载
评论 #6669228 未加载
评论 #6670159 未加载
评论 #6669157 未加载
评论 #6670723 未加载