Is it wise to use fractional / decimal pixels for

2019-03-29 07:35发布

问题:

I have various instances in my design that call for

border-right: 1.5px solid black;
border-bottom: 1.5px solid black;

etc...

I also have design that needs thinner lines: at 1px.

However, it seems the browser may round the decimal, as I'm not seeing much differentiation between the two (if any).

Should I just be using 2px and 1px instead, or is there a better way to pull this off?

A designer I'm helping is very adamant about the 1.5px line width.

Any help, much appreciated.

回答1:

You can use it, but most browsers will round pixel value.

http://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#values

http://ejohn.org/blog/sub-pixel-problems-in-css

http://cruft.io/posts/percentage-calculations-in-ie/

EDIT: Remember that one CSS pixel is not always equal to one physical screen pixel: A pixel is not a pixel is not a pixel