CSS中的像素(px)是多少? [英] What is a pixel (px) in CSS?
问题描述
我正在阅读一本ASP.NET书,它涉及CSS文件并谈论像素。但是我从未从分辨率,布局等角度理解它。例如,以下内容在CSS文件定义中是什么意思?
#header
{
padding:0px;
保证金:0px;
}
您可能正在使用,但是CSS像素不一定与显示器上的单个像素完全相同。根据规范:
如果输出设备的像素密度与典型的计算机显示器的像素密度非常不同,则用户代理应重新缩放像素值。建议参考像素为像素密度为96dpi且与阅读器之间的距离为一臂长的设备上一个像素的视角。
因此,如果您拥有不算作典型的极其昂贵的超高分辨率显示器之一,则浏览器和/或OS可能会选择重新定义像素是什么。 / p>
就CSS创作而言, px的有用定义是: px是等于未缩放HTML中的像素长度的< img>或CSS背景图片。
I am reading an ASP.NET book and it refers to CSS files and talks about pixels. But I never understood it from a resolution, layout, etc. point of view. For example, what does the following mean in CSS file definition?
#header
{
padding: 0px;
margin: 0px;
}
This is a little beyond where you might be at the moment, but a CSS pixel is not necessarily exactly the same size as a single pixel on your display. According to the spec:
If the pixel density of the output device is very different from that of a typical computer display, the user agent should rescale pixel values. It is recommended that the reference pixel be the visual angle of one pixel on a device with a pixel density of 96dpi and a distance from the reader of an arm's length.
So if you have one of those incredibly expensive extra-high-resolution displays that doesn't count as "typical", the browser and/or OS may choose to redefine what a "pixel" is.
The useful definition for a ‘px’ as far as CSS authoring is concerned is: a ‘px’ is the quantity of length equal to the pixel in an unscaled HTML <img> or CSS ‘background-image’.
这篇关于CSS中的像素(px)是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!