Skip to content

πŸ—‚ Atomic CSS (ACSS) - Block, Element, Modifier (BEM) - Object Oriented CSS (OOCSS) - Scalable Modular Architecture CSS (SMACSS)

License

Notifications You must be signed in to change notification settings

prod3v3loper/acss-bem-oocss-smacss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ACSS - BEM - OOCSS - SMACSS

Language Code size Repo size License Website

Atomic CSS (ACSS)

Block Element Modifier (BEM)

Object Oriented CSS (OOCSS)

Scalable Modular Architecture CSS (SMACSS)

This repository has some folder and file structure for you

Inside in this sample:

less/
|- _base/
|  |- _default.less
|  |- _config.less
|  |- _mixin.less
|  |- ... add more ...
|
|- _layout/
|  |- _l-default.less
|  |- _l-float.less
|  |- _l-margin.less
|  |- _l-grid.less
|  |- ... add more ...
|
|- _module/
|  |- _m-default.less
|  |- _m-button.less
|  |- ... add more ...
|
|- _state/
|  |- _s-default.less
|  |- ... add more ...
|
|- _theme/
|  |- _t-default.less
|  |- ... add more ...
|
|- application/
|  |- style.less
 
css/
|- style.css
_base

_config.less

_default.less

_mixin.less (less-mixins)

_layout

_l-default.less

_l-float.less

_l-margin.less

_l-grid.less (css-grids)

_module

_m-default.less

_m-button.less

_state

_s-default.less

_theme

_t-default.less

Usage

General Usage

In general you should include the folder less/ in build into your project folder structur and create your own ACSS BEM SMACSS OOCSS work as suggested in the docs for each ACSS BEM SMACSS OOCSS template.

ACSS

Atomic CSS

ACSS

.mt-20 {
    margin-top: 20px;
}

/* Or */

.fl {
    float: left;
}
<article class="mt-20">
    <img src="" alt="" title="" class="fl">
</article>

BEM

Block - Element - Modifier

BEM

/* This is the Block */
.block1 {}
.block2 {}

/* This is an element, that helps to form the block as a whole */
.block1__element1 {}
.block2__element2 {}

/* This modifies the element or a block*/
.block1--modifier1 {}
.block2--modifier2 {}

/* Block Element Modifier */
.block2__element1--modifier1 {}
.block2__element2--modifier2 {}
<header class="block1">
    <h1 class="block1__element1">
        <a class="block1--modifier1" href="https://www.tnado.com/">tnado SEO CMS</a>
    </h1>
</header>
<article class="block2 block2--modifier2">
    <h1 class="block2__element2">tnado SEO CMS</h1>
</article>
<article class="block2">
    <h1 class="block2__element2 block2__element2--modifier2">tnado SEO CMS</h1>
</article>

OOCSS

Object Oriented CSS

Separation of Structure From Skin. Here as example an ID was used and to which the skin was still defined.

This is not good readable and not good scaleable (PURE CSS):

/* No id but we have more buttons on the site */
#button {

    width: 200px;
    height: 50px;
    padding: 10px;
    border: solid 1px #ccc;
    background: linear-gradient(#ccc, #222);
    box-shadow: rgba(#000000,.5) 2px 2px 5px;
}

Good, you do this with preprocessors e.g. LESS or SASS:

Without acss prefix

/* LESS or SASS - OOCSS, BEM */

/* Give the button defaults */
.button {

    /* You can give here the padding but you need it not once */
    &__element {
        width: 200px;
        height: 50px;
        padding: 5px 10px; /* small applications use here otherwise use a helper file */
    }

    /* Give the button the modifier */
    &--skin {

        border: solid 1px #ccc;
        background: linear-gradient(#ccc, #222);
        box-shadow: rgba(#000000,.5) 2px 2px 5px;
    }
}
<button class="button__element button--skin">Send</button>

With acss prefix

/* LESS or SASS - OOCSS, BEM and ACSS */

/* Give the button defaults */
.l-button {

    /* You can give here the padding but you need it not once */
    &__element {

        width: 200px;
        height: 50px;
    }

    /* Give the button the modifier */
    &--skin {

        border: solid 1px #ccc;
        background: linear-gradient(#ccc, #222);
        box-shadow: rgba(#000000,.5) 2px 2px 5px;
    }
}

/* Give a helper padding with a prefix (ACSS) from helper file but in BEM style with two --, without BEM single - */
.p {

    &--10 {
        padding: 10px;
    }

    &--20 {
        padding: 20px;
    }

    &--30 {
        padding: 30px;
    }
}
<div class="l-button">
    <button class="l-button__element l-button--skin p--10">Send</button>
</div>

SMACSS

Scalable and Modular Architecture CSS.

Not good to use the elements directly nav > li

Augmented CSS:

nav li { 
    display: inline-block; 
}

/* or */
nav.nav-primary li { 
    display: inline-block; 
}

/* or */
nav.nav-secondary li,
nav.nav-primary li li {
    display: block;
}

Name all Elements to scale and create a modular Architecture.

SMACSS-style CSS (LESS):

/* LESS or SASS - SMACSS and BEM */

.l-inline {

    &__item { 
        display: inline-block;
    }
}

.l-stacked {

    /* nav.nav-primary li */
    &__item { 
        display: block;
    }

    /* nav.nav-primary li li */
    &__subitem { 
        display: inline-block;
    }
}
<nav>
    <ul class="l-inline">
        <li class="l-inline__item"><a href="https://www.tnado.com/">Home</a></li>
    </ul>
</nav>

<nav>
    <ul class="l-stacked">
        <li class="l-stacked__item">
            <a href="https://www.tnado.com/">Home</a>
            <ul class="l-stacked">
                <li class="l-stacked__subitem"><a href="https://www.tnado.com/">Home</a></li>
            </ul>
        </li>
    </ul>
</nav>

Mix

OCSS - ACSS - BEM - SMACSS

Better, you do on big applications this:

/* Prefix "m-" for module */
.m-button {

    height: 50px;

    /* Elements */
    &__big {
        width: 200px;
    }

    &__small {
        width: 100px;
    }

    /* Modifiers */
    &--default {

      border: solid 1px #ccc;
      background: linear-gradient(#ccc, #222);
      box-shadow: rgba(#000000,.5) 2px 2px 5px;
    }

    &--primary {

      border: solid 1px #ddd;
      background: linear-gradient(#ddd, #333);
      box-shadow: rgba(#ffffff,.5) 2px 2px 5px;
    }
}

/** 
 * ACSS with prefix
 * Prefix "l-" layout prefixer 
 * l-"p--" padding modifier
 * l-p--"10" 10px padding
 */
.l-p {
    &--10 {
        padding: 10px;
    }
    &--20 {
        padding: 20px;
    }
}
<button class="m-button m-button__small m-button--default l-p--10">Send</button>

Contribute

Please an issue if you think something could be improved. Please submit Pull Requests when ever possible.

Built with

NetBeans - NetBeans editor for error-free code

Authors

Samet Tarim - All works

License

GNU - prod3v3loper

About

πŸ—‚ Atomic CSS (ACSS) - Block, Element, Modifier (BEM) - Object Oriented CSS (OOCSS) - Scalable Modular Architecture CSS (SMACSS)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages