Answer the question
In order to leave comments, you need to log in
Is it worth switching completely from px to em?
Hello!
Now I use px sizes all over the place:
<div class="container">Содержание блока</div>
.container {
width: 200px;
padding: 5px;
font-size: 16px;
}
Answer the question
In order to leave comments, you need to log in
If relative units of measure suit you, then yes, it makes sense to switch to em / rem. If you need to specify the exact dimensions - px.
Everything depends on the task. If the site is responsive, it's highly recommended to use ems, preferably rem (they are now supported by all browsers since IE9). This will avoid a lot of problems.
If there is a possibility that you will need to change the scaling factor of all or most of the text on the site ("make all the text a little bigger, please"), it is also better to use relative values.
For everything else, you can safely use px. We recently started making mobile applications using Cordova, we use Framework7 - it also has everything in styles through px, although the layout is for mobile.
But for responsive sites, this is also not a hard and fast rule. If the transition to em is difficult, and the adaptive does not require proportional reduction of the entire text, px can also be dispensed with. The question is how big is the site and how will it grow in the future.
Plus, no one bothers to use part em, part px. Elements that require exact sizes defined in px can be specified in media queries with a separate css block. Boundless scope for creativity, in general :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question