svg学习笔记
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style type="text/css"> html,body{margin:0px;padding:0px;height: 100%;} #my-svg{ position:relative; height: 100%; width: 100%; } </style> </head> <body> <svg id="my-svg" xmlns="http://www.w3.org/2000/svg" version="1.1"> <!--线--> <line x1="60" y1="20" x2="260" y2="40" stroke="red" stroke-width="4"></line> <!--矩形--> <rect id="changePosition" x="20" y="20" rx="5" ry="5" width="30" height="30" fill="#e0e0e0" /> <rect id="changeSize" x="20" y="60" rx="5" ry="5" width="30" height="30" fill="lightgray" /> <rect id="changeOpacity" x="20" y="100" rx="5" ry="5" width="30" height="30" fill="lightgray" /> <!--圆形--> <circle cx="200" cy="200" r="50" stroke-width="2" stroke="#e0e0e0" fill="#E022FF"> <set attributeName="fill" from="#E022FF" to="#FF220E" begin="mouseover" end="mouseout"></set> <set attributeName="cx" from="200" to="300" begin="changePosition.mouseover" end="changePosition.mouseout"></set> <set attributeName="r" from="50" to="80" begin="changeSize.mousedown" end="changeSize.mouseup"></set> <animate attributeName="opacity" to="0" begin="changeOpacity.mouseover" dur="1s" fill="freeze"></animate> <animate attributeName="opacity" to="1" begin="changeOpacity.mouseout" dur="1s" fill="freeze"></animate> </circle> <!--椭圆--> <ellipse cx="400" cy="300" rx="50" ry="30" stroke="#e0e0e0" stroke-width="2" fill="#FF0000"></ellipse> <!--多边形--> <polygon points="400,20 450,50 425,90 375,90, 350,50" stroke="#e0e0e0" stroke-width="2" fill="#E942c0"></polygon> <!--多边--> <polyline points="400,120 450,150 425,190 375,190, 350,150" stroke="#cccccc" stroke-width="2" fill="white"></polyline> <!--路径--> <path d="M153 334 C153 334 151 334 151 334 C151 339 153 344 156 344 C164 344 171 339 171 334 C171 322 164 314 156 314 C142 314 131 322 131 334 C131 350 142 364 156 364 C175 364 191 350 191 334 C191 311 175 294 156 294 C131 294 111 311 111 334 C111 361 131 384 156 384 C186 384 211 361 211 334 C211 300 186 274 156 274" stroke="#FF0000" fill="white" stroke-width="1"></path> </svg> </body> </html>