SVG代表可缩放矢量图形,它是一种用XML描述2D图形和图形应用程序的语言,然后由SVG查看器呈现XML。
让我们看一个SVG的例子-
<!DOCTYPE html> <html> <head> <style> #svgelem { position: relative; left: 50%; -webkit-transform: translateX(-20%); -ms-transform: translateX(-20%); transform: translateX(-20%); } </style> <title>SVG</title> <meta charset="utf-8" /> </head> <body> <h2>HTML5 SVG Circle</h2> <svg id = "svgelem" height = "200" xmlns = "http://www.w3.org/2000/svg"> <circle id = "redcircle" cx = "50" cy = "50" r = "50" fill = "red" /> </svg> </body> </html>
要居中,请添加CSS,如下所示:
# svgelem { margin-left:auto; margin-right:auto; display:block; }