What's dp (density independent pixels) units with CSS?

前端 未结 8 1319
陌清茗
陌清茗 2020-12-23 10:39

For Android, people recommend using dp (density independent pixels) measurements for UI elements, and there are conventions that exist such as using 48dp for a

8条回答
  •  离开以前
    2020-12-23 11:23

    Use rem.

    It is the font size of the root element and a very good base unit for the size of other UI elements.

    If one used the same absolute size (in centimeter), the text and other elements would be much too big on mobile or much too small on desktop.

    If one used the same amount of pixels, the text and other elements would be much too small on mobile or much too big on desktop.

    The rem unit is on spot because it says "Hey, this is how big normal text should be." Basing the size of other UI elements on this is a pretty reasonable choice.

提交回复
热议问题