Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - Change Fill Color on Hover - SVG PATH

Tags:

html

css

svg

im using the modern ui icons pack in my project using the svg path.

what i try to do is to change the fill color on hover .

but i have no success..

hope someone help me out with this .

Thanks in advance.

Code:

<div id="Main">    <ul>       <li>           <form>              <button>                 <div class="inner">                    <svg>                      <path d="M35.......etc..">                      </path>                    </svg>                 </div>              </button>           </form>       </li>    </ul> </div 
like image 640
user2232273 Avatar asked Oct 03 '13 10:10

user2232273


People also ask

Can you change color of SVG on hover?

Target the . icon class in CSS and set the SVG fill property on the hover state to swap colors. This is by far the easiest way to apply a colored hover state to an SVG.

How do you change SVG fill using CSS?

You can't change the color of an image that way. If you load SVG as an image, you can't change how it is displayed using CSS or Javascript in the browser. If you want to change your SVG image, you have to load it using <object> , <iframe> or using <svg> inline.


1 Answers

You can overwrite svg fill color via css like below and also target different elements like <path> polygon circle etc.

#Main svg:hover {     fill: #fce57e; }  #Main svg:hover path {     fill: #fce57e; }  #Main svg:hover plygon {     fill: #fce57e; }  #Main svg:hover circle {     fill: #fce57e; } 
like image 106
Rajnikant Kakadiya Avatar answered Sep 25 '22 03:09

Rajnikant Kakadiya