css - 我的应用程序使用 rem 值。我如何将其与像素联系起来?

标签 css

我的浏览器宽度是 1440px,我想制作一个比浏览器屏幕宽度小一点的元素。所以只比 1440px 小一点。

谁能给我解释一下像素与 rem 的关系?我的浏览器如何决定 rem 单位中的像素数?

最佳答案

Can someone explain to me the way pixels relate to rem? How does my browser decide the number of pixels in a rem unit?

rem代表 root-em,它是根元素的字体大小。在 HTML 中,根元素是 <html> . UA 通常应用 font-size16pxhtml , 因此 1rem将等于 16px在那种情况下。

5.1.1. Font-relative lengths: the ‘em’, ‘ex’, ‘ch’, ‘rem’ units

Aside from ‘rem’ (which refers to the font-size of the root element), the font-relative lengths refer to the font metrics of the element on which they are used [...]

rem unit Equal to the computed value of ‘font-size’ on the root element.

When specified on the ‘font-size’ property of the root element, the ‘rem’ units refer to the property's initial value.

以及 font-size初始值是medium .

关于css - 我的应用程序使用 rem 值。我如何将其与像素联系起来?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26689637/

相关文章:

HTML:位于多行标签左侧的复选框输入

jquery - 在最后一张幻灯片上向下滚动时显示隐藏的页脚

javascript - Bootstrap 3 Gentelella 导航栏对齐到正确的问题

html - 无法覆盖不透明度值?

jquery - 滚动时更改按钮颜色,如蒙版

css - 使用 form-search 和 input-append 创建搜索表单时,搜索按钮显示较短

javascript - 检查数据属性和应用逻辑失败

jquery - 无法将 div 容器居中

javascript - 谷歌地图信息框位置

javascript - 使用 jQuery 和 CSS3 的视差窗帘显示效果