Skip to content

Latest commit

 

History

History
 
 

modules

Modules

Thinking modularly in CSS allows us to create more reusable CSS.


Examples

The common.css file used in the examples and videos could be replaced by your modular typography typography.css file for better results.

Videos

  1. Modules: list group
  2. Modules: buttons
  3. Modules: making modular icons
  4. Modules: combining the icons and the list group
  5. Modules: icon image replacement
  6. Modules: media object
  7. Modules: combining the media object and the list group
  8. Modules: media object alternatives
  9. Modules: embed containers
  10. Modules: embedding videos responsively
  11. Modules: embed containers with figures
  12. Modules: combining buttons with modular typography

Naming conventions

There are a couple major naming conventions for modular CSS that help clarify the intent of our classes and help us visualize the HTML by ust looking at the CSS classes.

Part of what we learned today comes directly from SMACSS: the icon naming conventions.

BEM takes naming a little further by using double underscores or double hyphens to represent certain ideas.

<div class="media media--highlighted">
  <div class="media__img"></div>
  <div class="media__body"></div>
</div>
  1. Name your component with a descriptive phrase, e.g. media
  2. Any classes that modify an original, base class, are separated with hyphens, e.g. media--highlighted
  3. Any classes that represent pieces that are inside of the original class, or sub-components, are separated with underscores, e.g. media__body

I find it helpful to remember that when using underscores the element is under the original component.

Videos


Links