<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xml:space="preserve" class="circle-load-rect-svg" width="300" height="200"
viewbox="0 0 600 400">
<polyline points="5 5, 575 5, 575 200, 5 200" class="g-rect-path"/>
<polyline points="5 5, 575 5, 575 200, 5 200" class="g-rect-fill"/>
</svg>
version: 表示 <svg> 的版本,目前只有 1.0,1.1 两种
xmlns:http://www.w3.org/2000/svg 固定值
xmlns:xlink:http://www.w3.org/1999/xlink 固定值
xml:space:preserve 固定值,上述三个值固定,表示命名空间,当数据单独存在svg文件内时,这3个值不能省略
class:就是我们熟悉的 class
width | height: 定义 svg 画布的大小
viewbox: 定义了画布上可以显示的区域,当 viewBox 的大小和 svg 不同时,viewBox 在屏幕上的显示会缩放至 svg 同等大小(暂时可以不用理解)
stroke-dasharray用来设置虚线,用“,”分隔的数字表示“实线,空”,stroke-dasharray=”5, 5” 。如果数字是奇数个的话,则自动补充为偶数。如 stroke-dasharray=”5,3,2” 实际为 “5,3,2,5,3,2”.
stroke-dashoffset用来表示偏移。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>svg边框动画特效</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="workarea">
<div class="svg-wrapper" style="position:absolute;top:200px;left:200px; border:1px solid red;">
<svg height="193" width="540" >
<rect id="shape" height="193" width="540" />
</svg>
</div>
</div>
</body>
</html>
style.css
@charset "utf-8";
#workarea{position:absolute;width:100%;height:100%;background-color:#1e1a3e;font-family:Raleway}
#shape{
stroke-width:6px;
fill:transparent;
stroke:#009FFD;
stroke-dasharray:83 650;
stroke-dashoffset:0;
-webkit-animation: draw 2s linear infinite;
animation: draw 2s linear infinite;
}
@-webkit-keyframes draw {
to {
stroke-dashoffset:733;
}
}
@keyframes draw {
to {
stroke-dashoffset:733;
}
}