简体   繁体   中英

Doubts on some Rules to be followed for Google material design

I'm trying to use material design concept for web app. In Google docs they have mentioned some spacing rules in dp.

在此处输入图片说明

Measurements in the above image are in dp and sp. ( Check here ) scroll down in that docs till specs section for field and label spacing measurements. To follow these measurements I cant figure out how to calculate px value from dp. The dp formula as mentioned in google docs is

dp = (width in pixels * 160) /  screen density

For formula

To use this formula I need Screen density. So Here is the question.

How do you calculate screen density from your web application?

From the Material Design Guildelines :

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

That means: You don't need to find out the screen density (which won't be easy to do anyway).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM