CSS命名BEM规范

css命名是前端开发经常遇到的问题,不同的开发人员css命名规范不同,不好合作,也不好维护。这里介绍一下css命名的BEM规范,即‘Block__Element--Modifier’(模块__元素--修饰符规范。BEM的命名规范是模块名加上双下划线(__),加上元素名,加上双短横线(--),最后加上修饰符。内部用短横线连接,举例说明:

// button
.btn{
  border: none;
  color: white;
}
.btn--red{
  background-color: red;
}
.btn--green{
  background-color: green;
}

// modal
.modal{
  
}
.modal__background{
  position: fixed;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  z-index: 10000;
}
.modal__window{
  
}
.modal__window-head{
  
}
.modal__window-body{
  
}
.modal__window-bottom{
  
}
.modal__window--big{
  
}

我们在实际的项目中,使用起来还是挺方便的。很容易找到。

原文地址:http://getbem.com/introduction/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值