What kind of web project does the poster want to complete? 1. Use px to fix the size and will not change with the device resolution. 2. The purpose of using % is to achieve a responsive page, which changes with the device resolution and adapts the width and height.
% is best not to be used in development, because it is really inaccurate. This size looks just right, but changing the size will cause problems.
If it is only on the PC side, using px is very accurate, but one problem is that if the UI needs to be changed, there may be many places that need to be changed, or if you want to have a certain adaptive effect, it may be more troublesome to do.
It is recommended to use rem or em. There will be many explanations about these two units on google
In fact, this has to be judged based on demand. It does not mean which one you use. The key is to determine whether the website to be developed is suitable for PC or mobile terminals, and whether it needs to be adaptive. This needs to be analyzed through website requirements. , rather than simply positioning whether % or px is better. If your website needs to adapt to multi-terminal use, it must be adaptive. If it is a more primitive PC-side website, px may sometimes be better displayed. If you are building your own website and really don’t know how to choose, I suggest you just use some front-end frameworks, such as bootstrap, which has integrated a whole set of effects such as self-adaptation
For PC, it would be better to choose px. For mobile phone, it would be more harmonious to choose %. Generally, the font selection is px, and rem is also used. In many cases, they are mixed. This depends on the specific needs.
On the web, PX is generally used. For mobile terminals, if meta is fixed, I usually mix px and %, because when meta and other values are fixed, px will scale proportionally, so it is generally OK, % is completely, Use this with caution
For example, if there is a p in the vertical direction inside a p, first you have to give the outer p the exact width of px, and then just use 100% for the width of the inner p, similar to this, like rem, em, vh, vw, These really depend on the situation. Generally, px is used relatively rarely on mobile terminals, unless you use media queries to write the style of each screen, which is also written in your own way
Use rem to directly set the font size unit of the body to 62.5% (=10px), and the subset elements in it directly write the corresponding rem value relative to the body
What kind of web project does the poster want to complete?
1. Use px to fix the size and will not change with the device resolution.
2. The purpose of using % is to achieve a responsive page, which changes with the device resolution and adapts the width and height.
rem. em is used to make responsive pages.
% is best not to be used in development, because it is really inaccurate. This size looks just right, but changing the size will cause problems.
If it is only on the PC side, using px is very accurate, but one problem is that if the UI needs to be changed, there may be many places that need to be changed, or if you want to have a certain adaptive effect, it may be more troublesome to do.
It is recommended to use rem or em. There will be many explanations about these two units on google
In fact, this has to be judged based on demand. It does not mean which one you use. The key is to determine whether the website to be developed is suitable for PC or mobile terminals, and whether it needs to be adaptive. This needs to be analyzed through website requirements. , rather than simply positioning whether % or px is better. If your website needs to adapt to multi-terminal use, it must be adaptive. If it is a more primitive PC-side website, px may sometimes be better displayed.
If you are building your own website and really don’t know how to choose, I suggest you just use some front-end frameworks, such as bootstrap, which has integrated a whole set of effects such as self-adaptation
It’s better to use px, personal opinion.
For PC, it would be better to choose px. For mobile phone, it would be more harmonious to choose %. Generally, the font selection is px, and rem is also used. In many cases, they are mixed. This depends on the specific needs.
Use px for web. If there is no special reason, don’t use %. It’s troublesome to write
On the web, PX is generally used. For mobile terminals, if meta is fixed, I usually mix px and %, because when meta and other values are fixed, px will scale proportionally, so it is generally OK, % is completely, Use this with caution
Existence is reasonable. When you should use %, use %. If you use px, use px. If you need to use rem, use rem
For example, if there is a p in the vertical direction inside a p, first you have to give the outer p the exact width of px, and then just use 100% for the width of the inner p, similar to this, like rem, em, vh, vw, These really depend on the situation. Generally, px is used relatively rarely on mobile terminals, unless you use media queries to write the style of each screen, which is also written in your own way
Use rem to directly set the font size unit of the body to 62.5% (=10px), and the subset elements in it directly write the corresponding rem value relative to the body