Rolling Your Own CSS Methodology
- 6. section {
color: black;
}
.page section {
color: blue;
}
.page section > ul {
color: black;
}
.page section > ul li:first-child {
color: blue;
}
@media only screen and (min-width: 480px) {
section,
.page section,
.page section > ul,
.page section > ul li:first-child {
color: orange;
}
}
- 7. section {
color: black;
}
.page section {
color: blue;
}
.page section > ul {
color: black;
}
.page section > ul li:first-child {
color: blue;
}
@media only screen and (min-width: 480px) {
section,
.page section,
.page section > ul,
.page section > ul li:first-child {
color: orange;
}
}
* {
color: black !important;
}
- 40. .button {
display: inline-block;
padding: 0.5rem 1rem;
border-radius: 3px;
color: #fff;
background: gradient($grey20, $grey18, 50%);
font-size: 1rem;
text-decoration: none;
}
.input {
display: inline-block;
padding: 0.5rem 1rem;
border-radius: 3px;
color: #000;
background: #fff;
font-size: 1rem;
text-decoration: none;
}
- 41. .button, input {
display: inline-block;
padding: 0.5rem 1rem;
border-radius: 3px;
font-size: 1rem;
text-decoration: none;
}
.button {
color: #fff;
background: gradient($grey20, $grey18, 50%);
}
.input {
color: #000;
background: #fff;
}
- 49. section {
color: black;
}
.page section {
color: blue;
}
.page section > ul {
color: black;
}
.page section > ul li:first-child {
color: blue;
}
@media only screen and (min-width: 480px) {
section,
.page section,
.page section > ul,
.page section > ul li:first-child {
color: orange;
}
}
* {
color: black !important;
}
- 78. THIS IS UNACCEPTABLE
.panel { display: block; margin: 1rem 0; font-size: 0.8rem; }
.panel .panel-wrapper { padding: 1.5rem; }
.panel .panel-list { width: 50%; float: left; }
.panel .panel-list ul.item-list { margin: 0; list-style: none; }
.panel .panel-list ul.item-list li.item { display: block; margin: 0.5rem 0; }
.panel .panel-list ul.item-list li.item a { font-weight: bold; }
.panel .panel-list ul.item-list li.item a:hover,
.panel .panel-list ul.item-list li.item a:focus { text-decoration: underline; }
.panel .panel-list ul.item-list li.item a span.prompt::before { content: "$ "; }
.panel .panel-list ul.item-list li.item a i { font-style: normal; }
- 91. HTML (ARGON)
<div class="swift-project -activeProject">
<div class="_filterList">
<input type="text" class="_filterField" />
<input type="text" class="_filterField" />
</div>
<button type="submit" class="_filterApply">
Okay
</button>
</div>
- 92. HTML (BEM)
<div class="swift-project--activeProject">
<div class="swift-project--activeProject__filterList">
<input type="text" class="swift-project--activeProject__filterField" />
<input type="text" class="swift-project--activeProject__filterField" />
</div>
<button type="submit" class="swift-project--activeProject__filterApply">
Okay
</button>
</div>
- 96. OTHER STUFF WE HAVE RULES FOR
• White space
• Style rule ordering
• File structure
• z-index scale
• Typography scale
• Grid system
• Colour
• etc.
- 97. FURTHER READING / WATCHING
• High-level advice and guidelines for writing sane, manageable, scalable CSS
• The Modular CSS (BEM/OOCSS) naming conundrum
• Medium’s CSS is actually pretty f***ing good.
• Slaying the Dragon: Refactoring CSS for Maintainability – Alicia Liu at Front-Trends 2014
• Code Refactoring for America
• Pixels are expensive
• Let’s Play Nice with CSS Tools & Methodologies – Brad Westfall at HTML5DevConf
- 133. FURTHER RESOURCES
• A Maintainable Style Guide
• Combine matching media queries with Grunt
• Setting up Sass and Compass with source maps
• Using source maps with Sass 3.3
• csste.st - The How and Why of CSS Testing
• Code refactoring for America