css - web开发中,html元素大小用%好,还是用px好?
迷茫
迷茫 2017-04-17 13:57:25
0
10
517

请详细的说说 给个地址自己看去也行。
我用笔记本开发,同事用的台式,1366 768 和 1920 1080 一看差别好大啊。
求给点指导

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(10)
阿神

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!