CSS Default Units

前端 未结 6 2041
日久生厌
日久生厌 2020-12-06 11:25

Can I change the default unit from pixel to mm? For example I want when move an element left and top to be in mm not in pixel?

6条回答
  •  一个人的身影
    2020-12-06 11:46

    There is no 'default unit'. The CSS spec requires that a length (other than zero) that is missing a unit be treated as an error (and thus ignored).

    In quirks mode (and you should almost never be using quirks mode, it makes life more difficult), most browsers will perform error recovery and assume you meant pixels (despite the spec forbidding this).

    If you are working with screen media — avoid physical units. Most systems are not calibrated to calculate the DPI correctly (so when converting from physical units into something a monitor understands (pixels) they get it wrong).

提交回复
热议问题