skip to Main Content

My code is shown below. However, nothing is applied to the svg. What is the best way to resolve this?

enter image description here

.icon {
    width: 250px;
    height: 250px;
    background-color: chartreuse;
}

.icon > svg {
    fill: brown;
    width: 100%;
    height: 100%;
}

2

Answers


  1. Remove the inline style fill="none", width="37" and height="36" from svg.

    Login or Signup to reply.
  2. A trick I use is to give a color property to the parent element, in this case .icon and have the svg css as fill: currentColor

    .icon {
      color: brown;
      /* Rest of your code */
    }
    
    .icon > svg {
      fill: currentColor;
      /* Rest of your code */
    }
    

    More details here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search