CSS-Naming-Conventions--BEM
BEM
BEM : Block Element Modifier
There are only two hard problems in Computer Sciences:cache invalidation and naming things --Phil Carlton
Block
Short prefix of namespacing. such as
.block
Naming:
Consist of Latin letters,digits and dashes. To form a CSS class,add a short prefix for namespace.
HTML
<div class="block">....</div>
CSS
.block {
color:red;
}
Element
A block name plus two underscore plus element name
Naming
.block__element
HTML
<div class="block">
<span class="block__element"> </span>
</div>
CSS
.block__element {
color:red;
}
Modifier
Block`s or element`s name plus two dashes.
.block--mod.block__element--mod
Naming
.block--mod
.block__element--mod
HTML
<div class="block block--mod">
<span class="block__element block__element--mod"></span>
</div>
CSS
- Use modifier class name as selector
.block--mod {
}
- To alter elements based on a block-level modifier
.block--mod .block__mod {
}
- Element modifier
.block__element--mod {
}
Examples
HTML
<form class="form form--theme-xmas for--simple">
<input class="form__input" type="text"/>
<input class="form__submit form__submit--disabled" type="submit"/>
</form>
CSS
.form {}
.form--theme--xmas {}
.form--simple {}
.form__input {}
.form__submit {}
.form__submit--disabled {}
Reference
CSS-Naming-Conventions--BEM的更多相关文章
- Effective Java 56 Adhere to generally accepted naming conventions
Typographical naming conventions Identifier Type Type Examples Package com.google.inject, org.joda.t ...
- Naming Conventions for .NET / C# Projects
http://www.akadia.com/services/naming_conventions.html Naming Conventions for .NET / C# Projects Mar ...
- C# Coding & Naming Conventions
Reference document https://msdn.microsoft.com/en-us/library/ff926074.aspx https://msdn.microsoft.com ...
- Spring mvc 4系列教程(二)——依赖管理(Dependency Management)和命名规范(Naming Conventions)
依赖管理(Dependency Management)和命名规范(Naming Conventions) 依赖管理和依赖注入(dependency injection)是有区别的.为了将Spring的 ...
- CSS命名规范——BEM思想(非常赞的规范)
人们问我最多的问题之一是在CSS类名中“--”和“__”是什么意思?它们的出现是源于BEM和Nicolas Gallagher... BEM的意思就是块(block).元素(element).修饰符( ...
- CSS命名规范 BEM
良好的代码结构,HTML和css元素之间的关系,对于项目交付是很重要的! BEM解释: (1).block 是BEM的区块(B),包含内容和风格.如bootstrap框架的.container. (2 ...
- 前端css命名规范----BEM
一.什么是BEM BEM就是块(block).元素(element).修饰符(modifier),是由Yandex团队提出的一种前端命名方法论.这种巧妙的命名方法可以使css类对其他开发者来说更加透明 ...
- css 命名规范 BEM
在项目的开发过程当中, 我们往往因为日益复杂的css代码而感到力不从心. 如何合理的组织css代码成为了我们前端开发过程中必须考虑到的环节. 在读element源代码的时候, 了解到了BEM的命名风格 ...
- css 命名规则 BEM!
随着CSS的发展,使用CSS有语义化的命名约定和CSS层的分离,将有助于它的可扩展性,性能的提高和代码的组织管理.著作权归作者所有. BEM本质应该是一个css命名方案,最流行的命名规则之一就是BEM ...
- css编写规则BEM
简单来说,格式如下: .block { /* styles */ } .block__element { /* styles */ } .block--modifier { /* styles */ ...
随机推荐
- 用贝叶斯定理解决三门问题并用Python进行模拟(Bayes' Rule Monty Hall Problem Simulation Python)
三门问题(Monty Hall problem)也称为蒙提霍尔问题或蒙提霍尔悖论,出自美国的电视游戏节目<Let’s Make a Deal>.问题名字来自该节目的主持人蒙提·霍尔(Mon ...
- Hdoj 1548.A strange lift 题解
Problem Description There is a strange lift.The lift can stop can at every floor as you want, and th ...
- 自学华为IoT物联网_06 智慧家庭物联网常见问题及解决方案
点击返回自学华为IoT物流网 自学华为IoT物联网_06 智慧家庭物联网常见问题及解决方案 1. 家庭中遇到的问题 2.1 华为智慧家庭概念的发展历程 2.2 华为智慧家庭的解决方案架构 智慧家庭主要 ...
- Centos7安装OpenDCIM-19.01步骤
Centos7安装OpenDCIM-19.01步骤 openDCIM是一款免费的开源解决方案,用于管理数据中心基础设施.它已经被几家企业组织所使用,由于开发人员的不懈努力,正在迅速完善. openDC ...
- THUSC2017题解
THUSC2017题解 题目都是在LOJ上交的. chocolate LOJ#2977巧克力 这题看着就让人想起了百度之星复赛的\(T5\),就是这题. 因为种类的个数很多,所以把每个种类随意\(ra ...
- visual studio 阅读 linux-kernel
@2018-12-13 [小记] 使用 visual studio 阅读 linux-kernel 方法 a. 文件 ---> 新建 --->从现有代码创建项目 b. 指定项目存储位置,命 ...
- hdu 2328 Corporate Identity(kmp)
Problem Description Beside other services, ACM helps companies to clearly state their “corporate ide ...
- C语言中的类型转换——将字符串s转换为整数型(int)类型
在讲类型转换之前,我们先要理解下C语言中单引号和双引号的区别. 先讲双引号,双引号就是字符串,我们要证实我们的想法,我选择写一段代码看看开: #include <stdio.h> int ...
- 深入学习semaphore
深入学习semaphore 控制同时访问资源线程数 访问特定资源前,先使用acquire(1)获得许可,如果许可数量为0,该线程则一直阻塞,直到有可用许可. 访问资源后,使用release()释放许可 ...
- Mock4 moco框架中如何加入cookies
新建一个 startupWithCookies.json,因为cookies也是请求当中带的,所以,要写在request里面,cookies是k-v的形式,就拿登陆来说吧,登陆以后会的cookies, ...