CSS速记vs长手? [英] CSS shorthand vs longhand?

查看:105
本文介绍了CSS速记vs长手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪一个更好?使用简写形式:

Which one better? Using shorthand like:

padding:5px 10px 15px 20px;

或使用长话:

padding-top:5px;
padding-right:10px;
padding-bottom:15px;
padding-left:20px;

相关:


  • 性能(浏览器效果,文件大小)

  • 文档(开发人员可轻松维护)

  • performance (browser performance, filesize)
  • documentation (easy maintenance by developer)
  • and others

推荐答案


  • 您不应担心CSS性能,除非您已经分析了页面加载,成为瓶颈(我怀疑,它几乎总是多个HTTP请求和图像)。

  • 任何有能力的开发人员可以从顶部顺时针记住值的顺序。

  • Shorthand意味着更少的字节被发送,CSS缩小器不会优化自己(我不认为)。

  • 我只使用long方法if一个值,例如 padding-left:3px

    • You shouldn't worry about CSS performance unless you have profiled the page load and it has became the bottleneck (I doubt, it is almost always multiple HTTP requests and images).
    • Any competent developer can remember clockwise from top for the order of values.
    • Shorthand means less bytes to be sent, which a CSS minifier doesn't optimise itself (I don't think).
    • I'd only use the long method if setting one value, e.g. padding-left: 3px.
    • 这篇关于CSS速记vs长手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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