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 button height, etc.
I'm working on a web application, and I'm getting a lot of criticism on the UI design saying it does not conform with Android design standards. Obviously, my application is going to look different since it is using CSS and HTML instead of the Android Holo theme, but I would still like to make it conform as much as possible. However CSS does not allow density independent measurements.
When I test my application on different resolutions and pixel densities, it does not look good, and sometimes, it is way out of proportion so it's not even functional. CSS doesn't have dp units like Android native development does, but I was wondering what some alternatives are.
Can I somehow get the pixel density using Javascript and manually scale everything appropriately? What is the best way for making a web app that looks and works nicely on all resolutions/densities?
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).