Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG background in firefox

Working on my friend's website and I can't figure out how to display the SVG right in Firefox. In Edge it also disappears while I'm resizing the browser.

http://lene.isreborn.com/

CSS - (I have to use important because it's Wordpress):

header::after {
    content:"";
    display: block;
    background: url(/svg-filer/header-background.svg);
    background-size: contain;
    background-repeat: no-repeat;
    top: 0;
    left:-1%;
    width: 102% !important;
    height: 90px !important;
    position: absolute;
    z-index: -1;

    -ms-transition: top ease .5s;
    -moz-transition: top ease .5s;
    -webkit-transition: top ease .5s;
    transition: top ease .5s;
}

header.sticky-active::after { 
    top: -20px;
}

SVG File:

  <?xml version="1.0" encoding="utf-8"?>
    <!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
    <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
         width="100%" height="90px" viewBox="0 0 1920 90" preserveAspectRatio="none">    
    <polygon id="XMLID_3_" fill="#FFFF00" points="1,99.7 1399.2,130 1921,99.7 1921,0 1,0 "/>
    </svg>
like image 710
Kevin Sass Avatar asked Oct 20 '16 10:10

Kevin Sass


People also ask

Can I use SVG as background image?

SVG images can be used as background-image in CSS as well, just like PNG, JPG, or GIF. All the same awesomeness of SVG comes along for the ride, like flexibility while retaining sharpness. Plus you can do anything a raster graphic can do, like repeat.

What is SVG enable background?

The enable-background attribute specifies how the accumulation of the background image is managed. Note: As a presentation attribute, enable-background can be used as a CSS property. You can use this attribute with the following SVG elements: <a> <defs>

Can I change SVG background color?

You can't adjust individual properties, like fill color, of an SVG background because it is treated just like any image.

How do I make SVG transparent?

The SVG way would be to set the stroke to none , or alternatively set the stroke-opacity to 0 . You also don't set any value for fill on the <rect> element and the default is black. For a transparent rect you want to add fill="none" .


1 Answers

I've got it right now: The background-size does not work with 'contain' but with 100% 100%, See Mozilla Background rules
Link to developer site: See here

header::after {
    content:"";
    display: block;
    background: url(/svg-filer/header-background.svg);
    background-size: 100% 100% !important;
    background-repeat: no-repeat;
    top: 0;
    left:-1%;
    width: 102% !important;
    height: 90px !important;
    position: absolute;
    z-index: -1;

    -ms-transition: top ease .5s;
    -moz-transition: top ease .5s;
    -webkit-transition: top ease .5s;
    transition: top ease .5s;
}

header.sticky-active::after { 
    top: -20px;
}
like image 84
Kevin Sass Avatar answered Oct 29 '22 15:10

Kevin Sass