Use class selectors and abandon ID selectors
The uniqueness of ID in a page means that if you write CSS with ID as the selector, it cannot be reused.
NEC special characters: "-" hyphen
"-" does not represent the meaning of a hyphen in this specification.
She only represents two meanings: classification prefix separator and expansion separator. Please refer to the following specific rules for details.
Category naming method: Use a single letter + "-" as the prefix
Layout (grid) (.g-); module (module) (.m-); component (unit) (.u-); function ( function) (.f-); skin (.s-); status (.z-).
Note: The selectors in your styles should always start with the first five categories, and then use descendant selectors inside.
If these five categories cannot meet your needs, you can define one or more additional categories, but they must comply with the naming rule of a single letter + "-" as the prefix, that is, the .x- format.
Special: .j- will be used exclusively for JS to get nodes, please do not use .j- to define styles.
Descendant selector naming
It is agreed that class selectors that are not prefixed by a single letter + "-" and have a length greater than or equal to 2 are descendant selectors, such as: .item is each item in the m-list module, .text It is the text part in the m-list module: .m-list .item{}.m-list .text{}.
A semantic tag can also be a descendant selector, such as: .m-list li{}.
Single-letter class selectors are not allowed. The reason is detailed in "Extended classes for descendant selectors of modules and components" below.
By using the descendant selector method, you don’t need to consider whether its name has been used, because it only takes effect in the current module or component. The same style name can be reused in different modules or components, regardless of each other. Interference; the effect is particularly obvious when multiple people collaborate or collaborate in sub-modules!
The descendant selector does not need to fully represent the structure tree level, and should be as short as possible.
Note: Do not use descendant selectors in page layouts because the possibility of contamination is greater;
/* 这里的.itm和.cnt只在.m-list中有效 */ .m-list{margin:0;padding:0;} .m-list .itm{margin:1px;padding:1px;} .m-list .cnt{margin-left:100px;} /* 这里的.cnt和.num只在.m-page中有效 */ .m-page{height:20px;} .m-page .cnt{text-align:center;} .m-page .num{border:1px solid #ddd;}
Names should be concise but not semantic
/* 反对:表现化的或没有语义的命名 */ .m-abc .green2{} .g-left2{} /* 推荐:使用有语义的简短的命名 */ .m-list .wrap2{} .g-side2{}
Different class naming with the same semantics
Method: Direct Just add numbers or letters to distinguish them (for example: .m-list, .m-list2, .m-list3, etc., are all list modules, but they are completely different modules).
Other examples: .f-fw0, .f-fw1, .s-fc0, .s-fc1, .m-logo2, .m-logo3, u-btn, u-btn2, etc.
The naming method of extended classes of modules and components
When A, B, C,... are of the same type and have similar appearance with little difference, then the one with the highest occurrence rate among them will be used as the base class, and the others will be used. An extension of the base class.
Method: + “-” + numbers or letters (for example: the extended classes of .m-list are .m-list-1, .m-list-2, etc.).
Addition: The base class itself can be used independently (for example: class="m-list"), and the extended class must be used based on the base class (for example: class="m-list m-list-2").
If your extension class represents different states, then you can name it like this: u-btn-dis, u-btn-hov, m-box-sel, m-box-hov, etc., and then use it like this: class ="u-btn u-btn-dis".
If your website is not compatible with browsers such as IE6, then your method of identifying status can also adopt the independent status classification (.z-) method: .u-btn.z-dis, .m-box.z-sel , and then use it like this: class="u-btn z-dis".
Extended classes for descendant selectors of modules and components
Sometimes there are similar things in modules. If you don’t make them into components and extensions, you can also use descendant selectors and extensions.
Descendant selector: .m-login .btn{}.
Descendant selector extensions: .m-login .btn-1{}, .m-login .btn-dis{}.
You can also take the independent status classification (.z-) method: .m-login .btn.z-dis{}, and then use it like this: class="btn z-dis".
Note: This method is used for class selectors. If you use labels directly as selectors, you do not need to use this naming method.
Note: In order to prevent the naming convention of extended classes and large classes of descendant selectors from conflicting, descendant selectors are not allowed to use a single letter.
For example: .m-list .a{} is not allowed, because when .a needs to be extended, it will become .a-bb, which conflicts with the naming convention of large categories.
Group selectors can sometimes replace extension methods
Sometimes although two modules of the same type are very similar, you hope there will be no dependency between them, which means you don’t want to use extension methods, then you can pass Combine selectors to set common styles.
The premise for using this method is: the same type, function and appearance are similar, and it is written in the same code area for easy maintenance.
/* 两个元件共性的样式 */ .u-tip1,.u-tip2{} .u-tip1 .itm,.u-tip2 .itm{} /* 在分别是两个元件各自的样式 */ /* tip1 */ .u-tip1{} .u-tip1 .itm{} /* tip2 */ .u-tip2{} .u-tip2 .itm{}
Prevent contamination and contamination
When modules or components are nested in each other and use the same label selector or other descendant selectors, then the selector inside will be selected by the same selector outside Influence.
So, if your module or component may be nested or nested within other modules or components, use tag selectors with caution, use class selectors when necessary, and pay attention to the naming method, you can use .m-layer .layerxxx , .m-list2 .list2xxx form to reduce the pollution of descendant selectors.

In a perfect world, our projects would have unlimited resources and time. Our teams would begin coding with well thought out and highly refined UX designs.

Oh, the Many Ways to Make Triangular Breadcrumb Ribbons

SVG has its own set of elements, attributes and properties to the extent that inline SVG code can get long and complex. By leveraging CSS and some of the forthcoming features of the SVG 2 specification, we can reduce that code for cleaner markup.

You might not know this, but JavaScript has stealthily accumulated quite a number of observers in recent times, and Intersection Observer is a part of that

We may not need to throw out all CSS animations. Remember, it’s prefers-reduced-motion, not prefers-no-motion.

PWA (Progressive Web Apps) have been with us for some time now. Yet, each time I try explaining it to clients, the same question pops up: "Will my users be

It's extremely surprising to me that HTML has never had any way to include other HTML files within it. Nor does there seem to be anything on the horizon that

There are a lot of different ways to use SVG. Depending on which way, the tactic for recoloring that SVG in different states or conditions — :hover,


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software