html - 边框小于1像素,这是怎么回事?

标签 html css firefox

我的页面上有一个输入框<input class='cv-input cv-dashboard-input'> ,定义了以下规则:

input.cv-dashboard-input {
    font-family: Roboto;
    font-weight: 300;
    color: #004d6f;
    border: 1px solid #adadad;
    border-radius: 0px;
    font-size: 14px;
    transition: all 0.3s;
    margin: 0;
    box-sizing: border-box;
}

input.cv-input {
    height: 42px;
    width: 100%;
    padding: 5px;
    font-family: Roboto;
    font-weight: 300;
}

当我在 Firefox 中检查此元素并检查其计算尺寸时,它指出我的边框宽度为 0.583333px。我以为最小渲染尺寸是 1 px,那么这是怎么发生的呢?

Here is a screenshot about what I see when I inspect the element in Firefox

我使用的是 Firefox 54.0.1(32 位)

最佳答案

使用CSS确实可以渲染0.5px。这个问题的答案很简单,CSS 中的 px 并不总是转换为计算属性上的一个像素,因为它可能会受到屏幕密度的影响。您可以在这里阅读更多相关信息:https://www.w3.org/TR/CSS21/syndata.html#length-units

我想提一下,我使用的是高 dpi 屏幕,这可以解释为什么我的计算属性非常准确。

顶部边框的顶部宽度为 0.5 像素。

Top has a border-top-width of 0.5px whilst the bottom is 1px all the way round.

The top input's computed properties

关于html - 边框小于1像素,这是怎么回事?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45522254/

相关文章:

css - Firefox retina 支持背景图片(媒体查询)

html - span 元素中的文本溢出未在元素宽度之外切割 texta

php - 我如何在 php 文件之间传递用户输入?

javascript - 使用 btn 对表单进行 HTML5 验证,触发 JS 函数发送 php 邮件并在成功时显示模式

css - SVG IMG 在 Firefox 中 float 时尺寸为零

javascript - jQuery - 如何将值插入 IE 和 Firefox 中的全局数组?

HTML/CSS - 链接不采用父 div 的宽度和高度,即使它们设置为 100%

html - 使用 HTML 和 CSS,如何使图像与水平线垂直对齐?

javascript - 尽管未显示 div,.js 文件是否应用两次?

html - 将 DOM 容器彼此和外部容器等距对齐