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

前端 未结 8 1322
陌清茗
陌清茗 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

    I disagree with the currently accepted answer. As uber5001 suggests, a px is a fixed unit, and in a similar spirit to the efforts of the Android-specifc dp.

    Per Material's spec:

    When writing CSS, use px wherever dp or sp is stated. Dp only needs to be used in developing for Android.

    Additionally

    When designing for the web, replace dp with px (for pixel).

提交回复
热议问题