Design comparison
Solution retrospective
hey everyone, hope you all are doing good, slowly getting the hang of how to layer pages yayy. I have a question regarding svg how can I change the color of it when I hover them I could only change the background color, please if you have any suggestions and ways I could have done this project better please comment and tell me would really appreciate it thank you and hopeyou have a good day/night.
Community feedback
- @mattari97Posted about 2 years ago
Hi Oduh Precious. Congratulations on completing this challenge.
To change the color of an svg using classes, you need to remove the hardcoded colors in the .svg file and replace it with "currentColor". This way you can manage the color of the svg with the CSS color property like it was text.
Hope this is helpfull. Have a good day/night. Peace ✌️
1 - @preciousoduhPosted about 2 years ago
Oh I see thank youuu. Please how do I remove the hard coded color?
0@mattari97Posted about 2 years ago@themusssee hey, open your editor (vscode, sublime text, atom, etc...) then navigate to you project and open the .svg file in there. You will see that it is just some text and more precisely an html component.
Search for colors in this text ; they look like this
#333333
and change them tocurrentColor
.Hope it helps.
Peace
Marked as helpful0@preciousoduhPosted about 2 years ago@AntoineC-dev okay thank you very much!!!! Hope you have a great day/night
1@mattari97Posted about 2 years ago@themusssee no problem.
I forgot to mention that for this solution to work you need to replace the
<img src="my-svg.svg" />
with the svg itself (the text i talked about in the previous comment). This is called using an inline svg in your html.0 - @preciousoduhPosted about 2 years ago
Oh thank you very much, hope you have a good day/night
0 - @TheMrBombasticPosted about 2 years ago
You can use background-color on pictures, but to see this they have to be transparent. Or you can chane the image, css does this with a background image command:
.svg{ width: 200px; height: 100px; (your picture dimensions) backgroundpicture: url(images/image1.svg);} .svg:hover{ backgroundpicture: url(images/image2.svg)}
this should work:)
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord