我应该在CSS中使用哪个单位,同时设计网页 [英] which unit i should use in CSS, while designing web page

查看:142
本文介绍了我应该在CSS中使用哪个单位,同时设计网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了超过10个网站,我仍然怀疑'我应该使用的正确单位'。无论是px,还是em或%。 Plz指导我走向正确的方向



编辑1:FOR LAYOUTS(特别是对于容器盒) =h2_lin>解决方案

不同的单位取决于上下文。



按照经验法则:


如果有一个最适合每种情况的单位,

如果您使用的是屏幕媒体:




  • 使用 > px em b
  • 使用线高的比率



如果您在印刷媒体工作:




  • 避免 px (这不是任何方式的硬规则),并且一切都是公平的游戏是明智的。这真的取决于你想要多少控制。


I deisgned more than 10 sites, still i had a doubt in mind of 'Whats the correct unit I should use'. Whether it is px, or em or %. Plz guide me to right direction

EDIT 1: FOR LAYOUTS (Especially for container boxes)

解决方案

Different units depending on context. If there was one that was best for every situation, then there wouldn't be so many units.

As rules of thumb go:

If you are working on screen media:

  • Use % for font sizes
  • Use px for images
  • Use px, %, or em for box sizes
  • Use ratios for line height

If you are working in print media:

  • It might be wise to avoid px (this is not a hard rule by any means) and everything else is fair game. It really depends how much control you want.

这篇关于我应该在CSS中使用哪个单位,同时设计网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆