Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Change svg fill color

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #239153
    Fritz
    Participant

    Hi,

    Is it possible to change the fill color of a svg by choosing a color from a dropdown menu ?

    Now I fixed it with changing the backcolor of a transparent png.
    example with changing backcolor.
    I’am making e new (responsive) site where I want to use svg’s.

    Fritz.

    #239154
    Paulie_D
    Member

    Sure…but the SVG has to be inline as far as I know.

    Or at least a <use> linked to an inline SVG. You can’t do it an SVG image…only an SVG element.

    Again, AFAIK.

    #239155
    Paulie_D
    Member

    Sure…but the SVG has to be inline as far as I know.

    Or at least a <use> linked to an inline SVG. You can’t do it an SVG image…only an SVG element.

    Again, AFAIK.

    #239158
    gezeichnet
    Participant

    No, its working with <use>. But your &lt;path&gt; elements may have no fill="" attribute.

    <svg viewBox="0 0 32 32" class="icon">
        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="file.svg#icon"></use>
    </svg>
    
    .icon {
        fill: red;
        /* for icons its nice to use 
        fill: currentColor
        */
    }
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.