gpt4 book ai didi

css - IE 中的 SVG 背景 repeat-x

转载 作者:行者123 更新时间:2023-11-28 09:02:51 27 4
gpt4 key购买 nike

我试图重复一个 SVG 水平作为背景,它在 Chrome 中工作正常但在 IE 中不行。我尝试了多种修复方法,但没有任何效果。我试过了

preserveAspectRatio="none slice"

描述here

SVG(部分):

<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>

完整示例页面:Here

最佳答案

你还需要设置一个background-size:

这里你需要:

.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>

关于css - IE 中的 SVG 背景 repeat-x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37354525/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com