Write CSS in a more logical way

Source: Internet
Author: User

Oocss and BEM

We encourage the use of some combination of oocss and BEM for the following reasons:

    • Can help us clarify the clear and rigorous relationship between CSS and HTML.

    • can help us create reusable, easy-to-assemble components.

    • You can reduce nesting and reduce the specific sex.

    • can help us create an extensible stylesheet.

oocss, or "Object oriented CSS", is a way to write CSS, and the idea is to encourage you to think of StyleSheets as a collection of "objects": creating reusable, repeatable snippets of code that you can use across your site multiple times.

Resources:

    • Nicole Sullivan's Oocss wiki

    • Smashing Magazine Introduction to Oocss

BEM, also known as "Block-element-modifier", is a naming convention for HTML and CSS class names. BEM was originally presented by Yandex, and to know that they had a huge code base and scalability, BEM was born to do so, and could be used as a set of reference guidelines to follow oocss.

    • CSS Trick for BEM 101

    • Harry Roberts's introduction to BEM

Example

<article class= "Listing-card listing-card--featured" >  

. listing-card {}.listing-card--featured {}.listing-card__title {}.listing-card__content {}
    • .listing-cardis a block that represents a high-level component.

    • .listing-card__titleis an element, which belongs to a .listing-card part, so the block is made up of elements.

    • .listing-card--featuredis a modifier (modifier) that indicates that the block .listing-card has a different state or change.

Oocss and BEM

We encourage the use of some combination of oocss and BEM for the following reasons:

    • Can help us clarify the clear and rigorous relationship between CSS and HTML.

    • can help us create reusable, easy-to-assemble components.

    • You can reduce nesting and reduce the specific sex.

    • can help us create an extensible stylesheet.

oocss, or "Object oriented CSS", is a way to write CSS, and the idea is to encourage you to think of StyleSheets as a collection of "objects": creating reusable, repeatable snippets of code that you can use across your site multiple times.

Resources:

    • Nicole Sullivan's Oocss wiki

    • Smashing Magazine Introduction to Oocss

BEM, also known as "Block-element-modifier", is a naming convention for HTML and CSS class names. BEM was originally presented by Yandex, and to know that they had a huge code base and scalability, BEM was born to do so, and could be used as a set of reference guidelines to follow oocss.

    • CSS Trick for BEM 101

    • Harry Roberts's introduction to BEM

Example

<article class= "Listing-card listing-card--featured" >  

. listing-card {}.listing-card--featured {}.listing-card__title {}.listing-card__content {}
    • .listing-cardis a block that represents a high-level component.

    • .listing-card__titleis an element, which belongs to a .listing-card part, so the block is made up of elements.

    • .listing-card--featuredis a modifier (modifier) that indicates that the block .listing-card has a different state or change.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.