如何在声明块中排序属性? [英] How to order properties in a declaration block?

查看:149
本文介绍了如何在声明块中排序属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道没有真正的对或错的答案。我只想听到CSS开发人员你喜欢订购你的属性,你的推理背后的偏好是什么。

I know there's no real right or wrong answer. I'd just like to hear from CSS developers how you like to order your properties and what is your reasoning behind your preference. Thank you very much.

推荐答案

我个人试图对属性进行更多或更少的分组:

  • box model (height, width, padding, margin...)
  • positioning
  • font related (font-family, font-weight, etc)
  • colours and background images

  • 箱子模型(高度,宽度,填充,边距...)

  • 定位

  • 字体相关(font-family,font-weight等)

  • 颜色和背景图片

There's no real benefit to doing things this way, I just find it reasonably logical and easy to follow.

以这种方式做事情没有什么实际的好处,我只是发现它合理的逻辑和容易跟随。

Quick example (with comments to illustrate):

快速示例(带注释) :

#selector{ /* box */ width: 300px; margin: 15px 0 30px; padding: 5px; border: 1px solid #333; /* position */ float: left; display: inline; /* font */ font-family: 'Lucida Grande', 'BitStream Vera Sans', Verdana, sans-serif; font-weight: normal; font-size: 14px; /* colour */ color: #000; background: #ddd; }

It's worth noting I usually keep the grouped selectors on one line (i.e. all box-related selectors on one line, and so on)

这篇关于如何在声明块中排序属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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