JS代码
// 容器 var box = document.getElementById("box"); // 创建svg var svg = document.createElementNS("http://www.w3.org/2000/svg","svg"); // svg添加到容器 box.appendChild(svg); // 创建图形 var rect = document.createElementNS("http://www.w3.org/2000/svg","rect"); // 设置矩形属性 rect.setAttribute("x","10"); rect.setAttribute("y","10"); rect.setAttribute("width","300"); rect.setAttribute("height","150"); rect.setAttribute("height","150"); rect.setAttribute("fill","black"); // 添加图形到svg svg.appendChild(rect);
HTML代码
<div id="box"></div>
svg 的dom命名空间和其他dom元素不一样。创建svg 元素需要用 createElementNS(namespace, ele); namespace 一般为“http://www.w3.org/2000/svg”
压缩概念及常见图片格式
王强推荐的创业者的知识架构
Python学习笔记
个人成效提升方法之遗愿清单
基于Jws的WebService项目
使用XSSFWork创建的xlsx后缀Excel文件无法打开
notepad++每行首尾添加内容
数据抓取的艺术(一):Selenium+Phantomjs数据抓取环境配置
使用PhantomJS实现网页截图服务