Reputation: 2240
I am trying to use Google Material Icons Sprite.. the CSS they are providing is something like this
.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);
}
The confusion is when i am trying to use
<div class="icon icon-ic_add_alert_white_24dp"></div>
It works Awesome... but when i put this...
<div class="icon icon-ic_add_alert_black_24dp"></div>
it doesn't work ... i think because the .icon is set multiple times and it takes either first or last value of .icon depending upon the browser..
.icon { background-image: ---------
but its Google they must have validated their CSS, Can you guide how it should work , i am new to Sprites...
REF
1) https://github.com/google/material-design-icons/tree/master/sprites
2) https://design.google.com/icons/
Please Help
Upvotes: 1
Views: 1542
Reputation: 84
try this
.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>
Upvotes: 1