SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Downloaden Sie, um offline zu lesen
Scalable and Modular
 Architecture for CSS

Flexible, maintainable patterns for large-
         scale web development
The Problem

The way we write CSS more complicated than it needs
to be.


.article #comments ul > li > a.button {}


Overly-specific rules create problems:
● when new features need to be added (flexibility)
● when other developers work on our code
  (maintainability).
Solutions


1. Categorization of styles
2. Naming conventions
3. Limiting "depth of applicability"
Categorization & Naming Conventions


1.   Base
2.   Layout
3.   Module
4.   State
Base Styles

Reset typography & unhelpful defaults.


html {
   background-color: #fff;
   font-family: Helvetica, Arial, sans-serif;
   font-size: 16px;
}


Reset stylesheets can be very redundant. normalize.css is a
better place to start, but strip out styles that are unlikely to be
utilized.
Layout Styles
Specify widths & margins, color & background.

.layout-sidebar {                .container_12 .grid_2 {
   float: left;                     float: left;
   width: 20%;                      margin-left: 10px;
}                                   margin-right: 10px;
                                    width: 140px;
                                 }




Define the major sections of your site. Can be semantic in
smaller systems, but a defined grid system scales better in
larger applications.
Module Styles

Discrete components in a system. The bulk of your styles.

.button {
   background-color: maroon;
   color: #fff
   display: inline-block;
   padding: .33em .5em;
   text-align: center;
}


<div class="container_12">
   <div class="grid_2">
       <a href="#" class="button">Buy Now</a>
   </div>
</div>
Sub-Module Styles

Variations on major elements.

.button-rounded {
   border-radius: 6px;
}

.button-large {
   font-size: 16px;
}


<div class="container_12">
   <div class="grid_2">
       <a href="#" class="button button-rounded">Buy Now</a>
   </div>
</div>
State Styles

Describes a module in a certain condition.

.is-hidden { display: none; }


Usually indicates a JavaScript dependency

Module-specific states should be namespaced:

.is-accordian-collapsed { height: 0;}
Depth of Applicability

Modules can be nested. Limit their impact.
#content a { color: #fa5400; }
#sidebar a { color: #333; }

.callout a { color: #90c3dd; }

#content .callout a,
#sidebar .callout a { color: #90c3dd; }

.callout a { color: #90c3dd !important; }


●   Avoid id selectors.
●   Use fewer selectors, ideally one.
●   Utilize child selectors to limit depth.
Child selectors
#nav ul li {
    color: #333;
    display: inline-block;
    margin: 0 10px;
}


#nav ul li ul li {
    background-color: #333;
    color: #fa5400;
    display: block;
    margin: 0;
}


.nav > li {
    color: #333;
    display: inline-block;
    margin: 0 10px;
}
.nav-sub > li {
    background-color: #333;
    color: #fa5400;
}
Practical Example: The Media Object
                               <div class="media">
                                   <div class="media-object">
                                        ...
                                   </div>
                                   <div class="media-body">
                                        ...
                                   </div>
                               </div>

                               .media { color: #999;
                               .media-object { float: left; }
                               .media-body { overflow: hidden;
                                             margin-left: 10px;
                               }




Abstracting styles into reusable modules can save hundreds of
lines of code.
Pain Points

"Object Oriented CSS" goes against conventional wisdom.

Separating modules & layout often means extra mark-up.

Class names may describe a visual state.
Resources

SMACSS (https://smacss.com/)
● Object Oriented CSS (https://github.
  com/stubbornella/oocss/wiki)
● CSS Wizardy (http://csswizardry.com/)
● BEM (http://bem.github.com/bem-
  method/pages/beginning/beginning.en.html)

Weitere ähnliche Inhalte

Was ist angesagt?

CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing worldRuss Weakley
 
Basics of Front End Web Dev PowerPoint
Basics of Front End Web Dev PowerPointBasics of Front End Web Dev PowerPoint
Basics of Front End Web Dev PowerPointSahil Gandhi
 
How to dominate a free theme WCTO 2014
How to dominate a free theme WCTO 2014How to dominate a free theme WCTO 2014
How to dominate a free theme WCTO 2014James Strang
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersSuzette Franck
 
How to use CSS3 in WordPress - Sacramento
How to use CSS3 in WordPress - SacramentoHow to use CSS3 in WordPress - Sacramento
How to use CSS3 in WordPress - SacramentoSuzette Franck
 
Responsive web design
Responsive web designResponsive web design
Responsive web designSean Wolfe
 
Steve Barman - CSS and WordPress
Steve Barman - CSS and WordPressSteve Barman - CSS and WordPress
Steve Barman - CSS and WordPressAnthony Montalbano
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3Jamshid Hashimi
 
Bootstrap webtech presentation - new
Bootstrap   webtech presentation - newBootstrap   webtech presentation - new
Bootstrap webtech presentation - newWebtech Learning
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layoutCK Yang
 
Web programming css
Web programming cssWeb programming css
Web programming cssUma mohan
 
Css for Development
Css for DevelopmentCss for Development
Css for Developmenttsengsite
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSSanjoy Kr. Paul
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSSdanpaquette
 

Was ist angesagt? (20)

CSS: a rapidly changing world
CSS: a rapidly changing worldCSS: a rapidly changing world
CSS: a rapidly changing world
 
Basics of Front End Web Dev PowerPoint
Basics of Front End Web Dev PowerPointBasics of Front End Web Dev PowerPoint
Basics of Front End Web Dev PowerPoint
 
How to dominate a free theme WCTO 2014
How to dominate a free theme WCTO 2014How to dominate a free theme WCTO 2014
How to dominate a free theme WCTO 2014
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress Developers
 
How to use CSS3 in WordPress - Sacramento
How to use CSS3 in WordPress - SacramentoHow to use CSS3 in WordPress - Sacramento
How to use CSS3 in WordPress - Sacramento
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
Full
FullFull
Full
 
Steve Barman - CSS and WordPress
Steve Barman - CSS and WordPressSteve Barman - CSS and WordPress
Steve Barman - CSS and WordPress
 
Css3
Css3Css3
Css3
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
 
Bootstrap Framework
Bootstrap Framework Bootstrap Framework
Bootstrap Framework
 
Bootstrap webtech presentation - new
Bootstrap   webtech presentation - newBootstrap   webtech presentation - new
Bootstrap webtech presentation - new
 
Css home
Css   homeCss   home
Css home
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layout
 
Web programming css
Web programming cssWeb programming css
Web programming css
 
Css for Development
Css for DevelopmentCss for Development
Css for Development
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Day6
Day6Day6
Day6
 

Ähnlich wie SMACSS Workshop

Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers PerspectiveMediacurrent
 
Intro to CSS Selectors in Drupal
Intro to CSS Selectors in DrupalIntro to CSS Selectors in Drupal
Intro to CSS Selectors in Drupalcgmonroe
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Erin M. Kidwell
 
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...thejibe
 
CSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersCSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersDarren Gideon
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4imdurgesh
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
Slow kinda sucks
Slow kinda sucksSlow kinda sucks
Slow kinda sucksTim Wright
 
Drupal tips 'n tricks
Drupal tips 'n tricksDrupal tips 'n tricks
Drupal tips 'n tricksJohn Tsevdos
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule皮馬 頑
 
Design Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPressDesign Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPressJesse James Arnold
 
Workflow Essentials for Web Development
Workflow Essentials for Web DevelopmentWorkflow Essentials for Web Development
Workflow Essentials for Web DevelopmentXavier Porter
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSZoe Gillenwater
 
Web I - 07 - CSS Frameworks
Web I - 07 - CSS FrameworksWeb I - 07 - CSS Frameworks
Web I - 07 - CSS FrameworksRandy Connolly
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LAJake Johnson
 

Ähnlich wie SMACSS Workshop (20)

Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Display Suite: A Themers Perspective
Display Suite: A Themers PerspectiveDisplay Suite: A Themers Perspective
Display Suite: A Themers Perspective
 
Intro to CSS Selectors in Drupal
Intro to CSS Selectors in DrupalIntro to CSS Selectors in Drupal
Intro to CSS Selectors in Drupal
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
One Div To Save Them All: Controlling Drupal Div's and Implementing a Modular...
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
 
CSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI DevelopersCSS101 - Concept Fundamentals for non UI Developers
CSS101 - Concept Fundamentals for non UI Developers
 
ViA Bootstrap 4
ViA Bootstrap 4ViA Bootstrap 4
ViA Bootstrap 4
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Slow kinda sucks
Slow kinda sucksSlow kinda sucks
Slow kinda sucks
 
Drupal tips 'n tricks
Drupal tips 'n tricksDrupal tips 'n tricks
Drupal tips 'n tricks
 
CSS- Smacss Design Rule
CSS- Smacss Design RuleCSS- Smacss Design Rule
CSS- Smacss Design Rule
 
Design Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPressDesign Systems, Pattern Libraries & WordPress
Design Systems, Pattern Libraries & WordPress
 
Class15
Class15Class15
Class15
 
Think Vitamin CSS
Think Vitamin CSSThink Vitamin CSS
Think Vitamin CSS
 
Workflow Essentials for Web Development
Workflow Essentials for Web DevelopmentWorkflow Essentials for Web Development
Workflow Essentials for Web Development
 
Dominate The Theme Layer
Dominate The Theme LayerDominate The Theme Layer
Dominate The Theme Layer
 
Highly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSSHighly Maintainable, Efficient, and Optimized CSS
Highly Maintainable, Efficient, and Optimized CSS
 
Web I - 07 - CSS Frameworks
Web I - 07 - CSS FrameworksWeb I - 07 - CSS Frameworks
Web I - 07 - CSS Frameworks
 
Sass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LASass Essentials at Mobile Camp LA
Sass Essentials at Mobile Camp LA
 

Kürzlich hochgeladen

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Kürzlich hochgeladen (20)

Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

SMACSS Workshop

  • 1. Scalable and Modular Architecture for CSS Flexible, maintainable patterns for large- scale web development
  • 2. The Problem The way we write CSS more complicated than it needs to be. .article #comments ul > li > a.button {} Overly-specific rules create problems: ● when new features need to be added (flexibility) ● when other developers work on our code (maintainability).
  • 3. Solutions 1. Categorization of styles 2. Naming conventions 3. Limiting "depth of applicability"
  • 4. Categorization & Naming Conventions 1. Base 2. Layout 3. Module 4. State
  • 5. Base Styles Reset typography & unhelpful defaults. html { background-color: #fff; font-family: Helvetica, Arial, sans-serif; font-size: 16px; } Reset stylesheets can be very redundant. normalize.css is a better place to start, but strip out styles that are unlikely to be utilized.
  • 6. Layout Styles Specify widths & margins, color & background. .layout-sidebar { .container_12 .grid_2 { float: left; float: left; width: 20%; margin-left: 10px; } margin-right: 10px; width: 140px; } Define the major sections of your site. Can be semantic in smaller systems, but a defined grid system scales better in larger applications.
  • 7. Module Styles Discrete components in a system. The bulk of your styles. .button { background-color: maroon; color: #fff display: inline-block; padding: .33em .5em; text-align: center; } <div class="container_12"> <div class="grid_2"> <a href="#" class="button">Buy Now</a> </div> </div>
  • 8. Sub-Module Styles Variations on major elements. .button-rounded { border-radius: 6px; } .button-large { font-size: 16px; } <div class="container_12"> <div class="grid_2"> <a href="#" class="button button-rounded">Buy Now</a> </div> </div>
  • 9. State Styles Describes a module in a certain condition. .is-hidden { display: none; } Usually indicates a JavaScript dependency Module-specific states should be namespaced: .is-accordian-collapsed { height: 0;}
  • 10. Depth of Applicability Modules can be nested. Limit their impact. #content a { color: #fa5400; } #sidebar a { color: #333; } .callout a { color: #90c3dd; } #content .callout a, #sidebar .callout a { color: #90c3dd; } .callout a { color: #90c3dd !important; } ● Avoid id selectors. ● Use fewer selectors, ideally one. ● Utilize child selectors to limit depth.
  • 11. Child selectors #nav ul li { color: #333; display: inline-block; margin: 0 10px; } #nav ul li ul li { background-color: #333; color: #fa5400; display: block; margin: 0; } .nav > li { color: #333; display: inline-block; margin: 0 10px; } .nav-sub > li { background-color: #333; color: #fa5400; }
  • 12. Practical Example: The Media Object <div class="media"> <div class="media-object"> ... </div> <div class="media-body"> ... </div> </div> .media { color: #999; .media-object { float: left; } .media-body { overflow: hidden; margin-left: 10px; } Abstracting styles into reusable modules can save hundreds of lines of code.
  • 13. Pain Points "Object Oriented CSS" goes against conventional wisdom. Separating modules & layout often means extra mark-up. Class names may describe a visual state.
  • 14. Resources SMACSS (https://smacss.com/) ● Object Oriented CSS (https://github. com/stubbornella/oocss/wiki) ● CSS Wizardy (http://csswizardry.com/) ● BEM (http://bem.github.com/bem- method/pages/beginning/beginning.en.html)