This content originally appeared on DEV Community and was authored by Blogger and Programmer
Did someone ever tell you to code like this?
something{
width: 100px;
height: 100px;
}
I can tell you straight on, unless completely necessary, do not code like that.
In a hypothetical situation, I might be a user with a phone that does not have a width of 100px, guess what happens then? The hypothetical user get's an ugly looking side scrolling bar. Even worse, the user might not get some of the content!
A suggestion
A better approach is to use view height(vh). Which basically displays content based on the screen size.
Here is another version of the code written previously.
something{
width: 30vw;
height: 30vh;
}
Now for a user with a device of a height of 300px, the user would be shown an object of 100px.
This content originally appeared on DEV Community and was authored by Blogger and Programmer
Blogger and Programmer | Sciencx (2022-05-09T07:07:08+00:00) Why you should not use pixels(px) in CSS. Retrieved from https://www.scien.cx/2022/05/09/why-you-should-not-use-pixelspx-in-css/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.