As the company's business increases, the needs become more and more, and the team continues to expand. We often encounter several people working together to complete the same work or maintain and modify other people's works. So what is the most important thing? What troubles you most? When we implement a page with complex performance, the CSS file will be more cumbersome. The numerous selectors and attributes are dazzling. So how to position it faster and how to write styles more efficiently? Writing CSS is ignored by many people. Regarding the writing style, I looked through the works of some well-known websites and found that horizontal rows have almost become the mainstream of major product projects. However, everyone has different ways of writing CSS, which leads to a reduction in our work efficiency. In order to work better together and maintain the consistency of CSS writing within the team, we reached a consensus after several twists and turns. The specific writing method is as follows: CSS attributes are written horizontally, selectors are written vertically, and a new line must be added after each "," (comma) ;
Example of code writing standards for the refactoring group: (The numbers are only for demonstration, and it is not recommended to use numbers in actual applications.)
.class_name_1 .class_name_1_1,
.class_name_2 .class_name_2_1 .class_name_2_1_1,
.class_name_3{style1:value; style2:value; styel3:value; }
Some people say that good code is a work of art even if it is opened with Notepad, and the style file itself is a design work. At present, there is no authority to define this specification. We can only make a simple summary of the two writing methods.
Compare the style files themselves:
Vertical writing features:
Existing problems: redundant code (such as space characters, tab characters, newline characters); increased file size; vertical scroll bars are prone to appear.