A
A
Alexander Lashchevsky2014-11-24 12:47:08
css
Alexander Lashchevsky, 2014-11-24 12:47:08

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;
}

Should I replace all px with em?
What will bring me less problems when imposition? Taking into account the fact that the site should be displayed normally both on standard monitors, and on desktop retina, and adaptively on mobile?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-11-24
Protko @Fesor

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.

T
teotlu, 2014-11-24
@teotlu

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 :)

A
asd111, 2014-11-24
@asd111

rem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question