addclass()和多类选择器结合使用提高代码规范

假设一个元素平时的样式为

A{

 ........

}

给该元素绑定点击事件,点击后添加类样式addclass('B');


则在css样式表中,B的样式最好不要写成

B{

 .......

}

而应该写成

A.B{

  .........

}

即多类选择器的样式

例子:

.cd-user-modal-container .cd-switcher a {
	display: block;
	width: 100%;
	height: 50px;
	line-height: 50px;
	background: #d2d8d8;
	color: #809191;
	 
}
.cd-user-modal-container .cd-switcher a.selected {
  background: #FFF;
  color: #505260;
  
}


你可能感兴趣的:(addclass()和多类选择器结合使用提高代码规范)