我想把一个svg-image中心和垂直中心响应我的窗口.所以我决定将图像整合到div背景中.现在,当我想将stroke-dasharray和动画与stroke-dashoffset添加到我的svg时它不起作用.
这个posibble是否可以为svg背景图像设置动画?
svg-image只包含许多行. 这里是我的svg文件(还有更多的行只有不同的x和y值):
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1920 1200" xml:space="preserve">
<g id="Layer_1">
<line class="path" stroke-linecap="round" fill="none" stroke="#FFFFFF" stroke-width="3" stroke-miterlimit="10" x1="960" y1="600" x2="2346.139" y2="-42.064"/>
</g>
</svg>Run Code Online (Sandbox Code Playgroud)
在这里我的Html和Css文件:
html, body {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
background-color: red;
}
.Container {
position: relative;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 100%;
height: 100%;
background-image: url(Space.svg);
background-size: cover;
background-position: center;
}
.path {
stroke-dasharray: 20;
}Run Code Online (Sandbox Code Playgroud)
<body>
<div class="Container">
</div>
</body>Run Code Online (Sandbox Code Playgroud)