有像分数像素这样的东西吗? [英] Is there such a thing as fractional pixel?

查看:96
本文介绍了有像分数像素这样的东西吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始帮助一些网页设计的同事。没有什么重要的,但我有一个样式的菜单元素,应该填充div区分配的问题,我注意到,虽然我可以通过在ff中添加小数点来调整宽度设置,但我注意到在铬中,上一个样式元素和div边框是巨大的。我检查了大小,并意识到铬以四舍五入的整数值显示大小(S)。任何人都有任何想法,为什么这是?

解决方案

小数像素没有这样的事情。 Pixel是最小的屏幕单位。

由于浏览器的数学引擎,所遇到的事情发生了。它们中的一些将小数像素部分舍入到下一个整数,并且其中一些将它放下。为了避免那只是定义没有小数点的像素。如果你想让两个视觉距离更近,你可以使用颜色进行游戏 - 例如,如果你给某些元素设置了较深的边框,它们看起来会更接近 - http://jsfiddle.net/fDbUj/

I just started helping some work colleagues with some web design. Nothing major, but I have a problem with styled menu elements that are supposed to fill div area allocated and I noticed that whilst I can tweak width settings in ff by adding decimal points in them I noticed that in chromium, the gap between the last styled element and the div border is huge. I Checked the size and realised that chromium is showing the size(S) in rounded integer value. Anyone have any idea as to why this is?

解决方案

There is no such thing as fractional pixel. Pixel is the smallest screen unit.

The thing you're experiencing happens because of the browsers math engines. Some of them round the decimal pixel part up to the next integer, and some of them floor it down.

To avoid that just define your pixels without decimal points. If you want to make the 2 elements visually closer you can play around with colors, for example - if you give a darker border to some elements they will seem to be closer - http://jsfiddle.net/fDbUj/

这篇关于有像分数像素这样的东西吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆