如何制作更好的CSS ID规则

时间:2016-05-27 12:20:02

标签: html css

我正在学习html + css并且有疑问,可以为几个ID编写规则,就像我必须达到目标一样

<!-- language: lang-css-->

 #menu-item-207 .menu-image-title {
   color: black !important;
 }
 #menu-item-207 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-206 .menu-image-title {
   color: black !important;
 }
 #menu-item-206 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-205 .menu-image-title {
   color: black !important;
 }
 #menu-item-205 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-204 .menu-image-title {
   color: black !important;
 }
 #menu-item-204 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-203 .menu-image-title {
   color: black !important;
 }
 #menu-item-203 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-202 .menu-image-title {
   color: black !important;
 }
 #menu-item-202 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-201 .menu-image-title {
   color: black !important;
 }
 #menu-item-201 .menu-image-title:hover {
   color: #0095d1 !important;
 }
 #menu-item-200 .menu-image-title {
   color: black !important;
 }

我怎样才能适应它?先感谢您!

2 个答案:

答案 0 :(得分:3)

您可以使用class,但不需要ID

.menu-image-title{
   color: black !important; 
}

.menu-image-title:hover{
   color: #0095d1 !important;
}

您可以同时在多个元素中使用class

答案 1 :(得分:0)

您可以使用逗号组合多个选择器:

Alloy.Globals.Facebook = require('facebook');
Alloy.Globals.Facebook.permissions = ['public_profile'];