- Use kebab case for naming your css code
.myClass {
cursor: pointer;
height: 200px;
width: 100px;
}
.my-class {
cursor: pointer;
height: 200px;
width: 100px;
}
- Use css variables instead scss ones
$colors = (
myColor: #f829ff,
)
:root {
my-color: #f829ff;
}
- Order css properties in alphabetical order
.my-class {
width: 100px;
cursor: pointer;
height: 200px;
}
.my-class {
cursor: pointer;
height: 200px;
width: 100px;
}
- Keep nested classes at two/three levels maximun
.my-module {
.nested-module {
.another-nested-module {
.other-more {
}
}
}
}
.my-module {
.nested-module {
}
}
- Avoid ID selectors
#my-module {
}
.my-module {
}
- Always put a space between properties and their value
.my-class {
width:100px;
}
.my-class {
width: 100px;
}
- Always leave a blank space separation between two classes
.my-class {
width:100px;
}
.my-other-confusing-class {
height: 200px;
}
.my-class {
width: 100px;
}
.now-i-get-it-class {
height: 200px;
}
- In a flex item always control width/height using flex-basis
.my-flex-item {
width: 50%;
}
.my-flex-item {
flex-basis: 50%;
}
- Never use transition all
.selector-to-animate {
transition: all 0.2s ease-in;
}
.selector-to-animate {
transition: transform 0.2s ease-in;
}