1

我正在尝试使用 Google Material Icons Sprite .. 他们提供的 CSS 是这样的

.icon {
  background-image: url(../images/sprite-alert-white.PNG);
}
.icon-ic_add_alert_white_24dp {
  background-position: -0px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_error_outline_white_24dp {
  background-position: -32px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_error_white_24dp {
  background-position: -0px -32px;
  width: 32px;
  height: 32px;
}
.icon-ic_warning_white_24dp {
  background-position: -32px -32px;
  width: 32px;
  height: 32px;
}
.icon {
  background-image: url(../images/sprite-alert-black.PNG);
}
.icon-ic_add_alert_black_24dp {
  background-position: -0px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_error_black_24dp {
  background-position: -32px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_error_outline_black_24dp {
  background-position: -0px -32px;
  width: 32px;
  height: 32px;
}
.icon-ic_warning_black_24dp {
  background-position: -32px -32px;
  width: 32px;
  height: 32px;
}
.icon {
  background-image: url(../images/sprite-toggle-white.PNG);
}
.icon-ic_check_box_outline_blank_white_24dp {
  background-position: -0px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_check_box_white_24dp {
  background-position: -32px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_indeterminate_check_box_white_24dp {
  background-position: -0px -32px;
  width: 32px;
  height: 32px;
}
.icon-ic_radio_button_checked_white_24dp {
  background-position: -32px -32px;
  width: 32px;
  height: 32px;
}
.icon-ic_radio_button_unchecked_white_24dp {
  background-position: -64px -0px;
  width: 32px;
  height: 32px;
}
.icon-ic_star_border_white_24dp {
  background-position: -64px -32px;
  width: 32px;
  height: 32px;
}
.icon-ic_star_half_white_24dp {
  background-position: -0px -64px;
  width: 32px;
  height: 32px;
}
.icon-ic_star_white_24dp {
  background-position: -32px -64px;
  width: 32px;
  height: 32px;
}
.icon {
  background-image: url(../images/sprite-toggle-black.PNG);
}

困惑是当我试图使用

<div class="icon icon-ic_add_alert_white_24dp"></div>

它的工作原理太棒了......但是当我把这个......

 <div class="icon icon-ic_add_alert_black_24dp"></div>

它不起作用......我认为是因为 .icon 设置了多次,并且它需要.icon的第一个或最后一个值,具体取决于浏览器..

.icon { 背景图像: ---------

但它的谷歌他们一定已经验证了他们的 CSS,你能指导它应该如何工作吗,我是 Sprites 的新手......

参考

1) https://github.com/google/material-design-icons/tree/master/sprites

2) https://design.google.com/icons/

请帮忙

4

1 回答 1

1

尝试这个

.icon {
  background-image: url(../images/sprite-alert-white.PNG);
}
.iconBlack {
  background-image: url(../images/sprite-alert-black.PNG);
}
<div class="iconBlack icon-ic_add_alert_black_24dp"></div>

于 2016-10-05T13:48:30.237 回答