There are probably as many modular solutions for CSS as there are for JS. Here is a brief introduction to several major modular solutions. oocss There are two main principles for object-oriented rules: separation of structure and appearance, and separation of container and content. Glossary
Examples // DOM structure <div class="toogle simple"> <div class="toogle-control open"> <div class="toogle-tittle">Title</div> </div> <div class="toogle-details"></div> </div> // Module's unique identifier.toggle{ } // How to write skin styles. If the basic structure is the same, you can use an auxiliary style of complex.toggle.simple{ } // Whether to do nested writing. I believe that many preprocessor parts will support nesting and many people will write like this, which is not recommended. toogle{ .toogle-control{ } .toogle-details{ } } // Actually, would you organize it this way? It is not recommended. This will reduce the query efficiency. If you can confirm the uniqueness, you can just write the subdirectory.toogle{} .toogle-control{} .toogle-details{} smacss SMA and OOCSS have many similarities, but there are many differences, mainly in the classification of styles. They are: basic, layout, module, state, theme Base Can be applied anywhere, I also call it global style layout It is mainly used to realize different characteristic layouts and improve the reuse rate of layouts. Modules Modularity in design, a reusable unit, is generally a coupled binding of DOM+CSS. state Describe the specialized performance of the layout or module in a specific state. Here I would like to recommend "CSS Zen Garden". When the DOM structure remains unchanged, the style can be modified through CSS skinning. theme Compared with the status, it is more customized. We will set the theme for some special modules, including a series of colors, sizes, interactions, etc. for heavy design and parametric design. Case // DOM structure <div class="toogle toogle-simple"> <div class="toogle-control is-active"> <div class="toogle-tittle">Title</div> </div> <div class="toogle-details"></div> </div> Compared with oocss, most of the design ideas are the same, using a class as the scope of CSS (scope means two restrictions: 1. It is prohibited to use when it does not meet the scenario; 2. It must be used correctly when it meets the scenario). The other difference is the different writing rules for skins and states. bem bem is to write styles with the thinking of blocks, elements, and modifiers. It does not involve specific CSS structure, but just suggests how to name your CSS. Case // DOM structure <div class="toogle toogle--simple"> <div class="toogle_control toogle_control--active"> <div class="toogle_tittle">Title</div> </div> <div class="toogle_details"></div> </div> explain
The disadvantage of this naming method is that the style name will be very long, but in fact it is used to a certain extent in smacss and oocss. The naming is very semantic. When the module is not clear, we can deduce what the corresponding structure may be based on the style name. Choose the right solution No matter which solution is chosen, the key is which one is most suitable for the team. Our current approach is a combination of bem and smacss. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: How to install Windows Server 2008 R2 on Dell R720 server
>>: HTML page header code is completely clear
Page domain relationship: The main page a.html bel...
This article does not have any quibbles, it is jus...
In the horizontal direction, you can set the cell...
Dynamically implement a simple secondary menu Whe...
This article example shares the specific code of ...
Ubuntu Server 16.04 MySQL 8.0 installation and co...
MySQL 8 new features: My personal opinion on MySQ...
Basically all e-commerce projects have the functi...
Quick Reading Why do we need to monitor SQL state...
Table of contents Overview Button-level permissio...
In response to the popularity of nodejs, we have ...
1. Connect to MYSQL Format: mysql -h host address...
Preface: Use the element framework in vue3.0, bec...
1. Install Oracle There are too many Oracle insta...
1. Introduction When we log in to MySQL, we often...