Using the CSS filter declaration to invert colors of svg icons loaded via an img element. #30630
-
Using Bootstrap icons in img element on a black background is problematic, because all the SVG strokes are black, there is a really quick fix, that's kind of hard not to use: Using the filter CSS declaration to invert it. Having icons with context/theme colors would make a huge css, so in many cases icons just need to be black or white, this tiny trick does the job. I wouldn't consider it a feature for bootstrap.css but it could be worth mentioning in icon docs. <img src="/icons/tag.svg" alt="" width="16" height="16" style="filter: invert(1);"> I hope I am posting in the right place (my first bootstrap post), |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
If you have feedback on the Bootstrap Icons, use that repo and not this one for any and all feedback, requests, bugs, etc. |
Beta Was this translation helpful? Give feedback.
-
as an aside, i'd say that including SVGs with |
Beta Was this translation helpful? Give feedback.
-
The text template under "New Issue" button here on twbs/bootstrap mentioned I should open a discussion if it is not a bug or feature, so I did follow that. But that boilerplate text needs to be updated to say that icons have their own repo with their own docs, sorry mdo. I've been learning bootstrap for years, but I am not part of the community and I don't know where to talk. I will take more care before posting something, and try slack first. Bootstrap made me a better programmer, Thank You, all. |
Beta Was this translation helpful? Give feedback.
as an aside, i'd say that including SVGs with
<img>
loses quite a bit of the advantages of the SVGs, such as the easy stylability / how they adapt tocurrentColor
, etc (as the<img>
creates a completely detached new content that is not aware of what the current color of the bit where is was included in is)