Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG background repeat-x in IE

I've tried to repeat a SVG horizontal as a background and it works fine in Chrome but not in IE. I tried multiple ways fixing it but nothing works. I tried

preserveAspectRatio="none slice"

as described here

SVG(part of):

<svg version="1.1" id="Ebene_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 viewBox="0 0 1000 1000" style="enable-background:new 0 0 1000 1000;" xml:space="preserve">

CSS:

.wave {
background-image: url(../images/wave.svg);
height: 150px;
margin: 0 auto;
margin-top: -150px;
background-repeat: repeat-x; }

HTML:

<div class="wave"></div>

Full examplepage: Here

like image 964
itspat Avatar asked Dec 11 '22 16:12

itspat


1 Answers

you need to set also a background-size:

here you need:

.wave {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/wave.svg);
    height: 150px;
    margin: 0 auto;
    margin-top: -150px;
    background-repeat: repeat-x;
  background-size:150px 150px;
    overflow:hidden
}

* {
    margin: auto;
    padding: 0;
}

body {
    background-color: white;
}

h1 {
    text-align: center;
    color: #212121;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 40px;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    top: 17vh;
    line-height: 1.2;
}

a {
    color: #212121;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 30px;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    line-height: 1.2;
    text-decoration: underline;
    text-align: center;
    margin: 0 auto;
    top: 10px;
}

h3 {
    text-align: center;
    color: #212121;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 40px;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    top: 17vh;
    line-height: 1.2;
}

.water {
    background-color: #E4F2EF;
    width: 100%;
    height: 40vh;
    bottom: 0;
    position: fixed;
}

.wave {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/wave.svg);
    height: 150px;
    margin: 0 auto;
    margin-top: -150px;
    background-repeat: repeat-x;
  background-size:150px 150px;
    overflow:hidden
}

.bottlepost {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/bottlepost.svg);
    height: 150px;
    background-repeat: no-repeat;
    margin-left: 30vw;
}

.bottlepost2 {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/bottlepost2.svg);
    height: 120px;
    background-repeat: no-repeat;
    margin-left: 60vw;
    margin-top: -90px;
}


/* Fish */

.fish {
    width: 100px;
    height: 100px;
    top: 50%;
    right: 50%;
    background: #CE716C;
    position: absolute;
    animation: 10s fly infinite linear;
    transform: translateX(-50%);
}


/* Shadow */

.shadow {
    width: 100px;
    height: 20px;
    background: rgba(0, 0, 0, .15);
    position: absolute;
    top: 310px;
    animation: 10s fly2 infinite linear;
    border-radius: 50%;
}


/* Eye */

span:nth-of-type(1) {
    width: 10px;
    height: 10px;
    background: #e4f2ef;
    border-radius: 50%;
    z-index: 9;
    display: inline-block;
    position: absolute;
    margin: 70px 0 0 7px;
}


/* Fish tail fin */

span:nth-of-type(2) {
    width: 50px;
    height: 50px;
    background: #CE716C;
    position: absolute;
    top: -25px;
    left: 70px;
}

span:nth-of-type(3) {
    width: 50px;
    height: 50px;
    background: #e4f2ef;
    position: absolute;
    top: -50px;
    left: 95px;
}


/* Fish fly */

@keyframes fly {
    0%,
    100% {
        right: 10%;
        transform: rotateY(180deg) rotate(45deg);
        top: 150px;
    }
    1% {
        transform: rotateY(0deg) rotate(45deg);
    }
    25% {
        top: 180px;
    }
    49% {
        transform: rotateY(0deg) rotate(45deg);
    }
    50% {
        right: 90%;
        top: 150px;
        transform: rotateY(180deg) rotate(45deg);
    }
    75% {
        top: 180px;
    }
}


/* Shadow fly */

@keyframes fly2 {
    0%,
    100% {
        right: 10%;
        transform: rotateY(180deg);
        width: 60px;
        height: 10px;
    }
    1% {
        transform: rotateY(0deg);
    }
    25% {
        width: 100px;
        height: 20px;
    }
    49% {
        transform: rotateY(0deg);
    }
    50% {
        right: 90%;
        transform: rotateY(180deg);
        width: 60px;
        height: 10px;
    }
    75% {
        width: 100px;
        height: 20px;
    }
}


/* 404 */

.fishs1 {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/fish.svg);
    height: 150px;
    background-repeat: no-repeat;
    margin-left: 20vw;
    margin-top: -120px;
}

.fishs2 {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/fish2.svg);
    height: 100px;
    background-repeat: no-repeat;
    margin-left: 50vw;
    margin-top: -300px;
}

.fishs3 {
    background-image: url(http://ineedhelp.tk/svgrepeat/images/fish3.svg);
    height: 80px;
    background-repeat: no-repeat;
    margin-left: 75vw;
    margin-top: 30px;
}

h6 {
    text-align: center;
    color: #5DACAF;
    font-family: 'Josefin Sans', sans-serif;
    font-weight: 300;
    font-size: 35vh;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    margin-bottom: 10px;
    line-height: 1.2;
    text-shadow: 5px 5px rgba(33, 33, 33, 0.08);
}
<h3><b>Hello</b>, my page is coming soon.<br></h3>
    <div class="water">
        <div class="wave"></div>
        <h6>404</h6>
        <div class="fishs1"></div>
        <div class="fishs2"></div>
        <div class="fishs3"></div>
    </div>
like image 177
G-Cyrillus Avatar answered Dec 30 '22 04:12

G-Cyrillus