Can I add color to bootstrap icons only using CSS?

后端 未结 14 1485
说谎
说谎 2020-11-28 02:58

Twitter\'s bootstrap uses Icons by Glyphicons. They are \"available in dark gray and white\" by default:

14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 03:35

    The accepted answer (using font awesome) is the right one. But since I just wanted the red variant to show on validation errors, I ended using an addon package, kindly offered on this site.

    Just edited the url paths in css files since they are absolute (start with /) and I prefer to be relative. Like this:

    .icon-red {background-image: url("../img/glyphicons-halflings-red.png") !important;}
    .icon-purple {background-image: url("../img/glyphicons-halflings-purple.png") !important;}
    .icon-blue {background-image: url("../img/glyphicons-halflings-blue.png") !important;}
    .icon-lightblue {background-image: url("../img/glyphicons-halflings-lightblue.png") !important;}
    .icon-green {background-image: url("../img/glyphicons-halflings-green.png") !important;}
    .icon-yellow {background-image: url("../img/glyphicons-halflings-yellow.png") !important;}
    .icon-orange {background-image: url("../img/glyphicons-halflings-orange.png") !important;}
    

提交回复
热议问题