點評:如果svg代碼在html中,我們就更容易寫javascript來控制圖形的變換,下面為大家介紹一些svg的預定義的形狀元素,感興趣的朋友可以參考下哈,希望對大家有所幫助
SVG 文件可通過以下標簽嵌入 HTML 文檔:<embed>、<object>或者<iframe>。復制代碼
代碼如下:
<embed src="rect.svg"height="100"
type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/"/>
復制代碼
代碼如下:
<object data="rect.svg"width="300"
type="image/svg+xml"
codebase="http://www.adobe.com/svg/viewer/install/"/>
<iframe src="rect.svg"height="100">
</iframe>
復制代碼
代碼如下:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
復制代碼
代碼如下:
<svg version="1.1"
xmlns="http://www.w3.org/2000/svg">
<ellipse cx="240" cy="100" rx="220" ry="30"
style="fill:yellow"/>
<ellipse cx="220" cy="100" rx="190" ry="20"
style="fill:white"/>
</svg>
復制代碼
代碼如下:
<script type="text/javascript">
function ccc(){
var a = document.getElementById("w1");
a.style.fill="red";
a.setAttribute("cx", "150"); //設置值
a.setAttribute("ry", "50"); //設置值
}
</script>
新聞熱點
疑難解答