锦方的个人网页 · 如果有一天你突然想起了我


HTML SVG

目录

SVG预定义形状

Rectangle Circle Ellipse Line Polyline Polygon Path

SVG在线编辑器: https://c.runoob.com/more/svgeditor/ SVG参考: https://www.w3schools.com/graphics/svg_reference.asp

rect:

<svg width="200" height="100">
  <rect width="30" height="80" 
  fill="blue" stroke="#000" stroke-width="3" />
  <rect x="33" y="0" width="50" height="80"
//x属性定义矩形的左侧位置
//y属性定义矩形的顶部位置
  fill="blue" stroke="pink" stroke-width="3" fill-opacity="0.1" stroke-opacity="0.9" />
//fill-opacity属性定义填充颜色的不透明度(法定范围:0到1)
//stroke-opacity属性定义笔画颜色的不透明度(法定范围:0到1)
  <rect x="86" y="0" width="10" height="80"
  fill="blue" stroke="pink" stroke-width="4" opacity="0.4" />
//opacity属性定义整个元素的不透明度值(法定范围:0到1)
  <rect x="100" y="0" rx="10" ry="10" width="95" height="80"
//rx和ry属性舍入矩形的角
  fill="red" stroke="black" stroke-width="5" opacity="0.5" />
  <rect x="0" y="80" width="200" height="17" 
  fill="blue" stroke="#000" stroke-width="1" />
</svg>
//fill-opacity属性定义填充颜色的不透明度(法定范围:0到1) //stroke-opacity属性定义笔画颜色的不透明度(法定范围:0到1) //opacity属性定义整个元素的不透明度值(法定范围:0到1)

circle:

<svg height="100" width="100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
//cx和cy属性定义了圆心的x和y坐标.r属性定义圆的半径
</svg>
//cx和cy属性定义了圆心的x和y坐标.r属性定义圆的半径

ellipse:

<svg height="400" width="400">
  <ellipse cx="200" cy="80" rx="100" ry="50"
//cx属性定义椭圆中心的x坐标
//cy属性定义椭圆中心的y坐标
//rx属性定义水平半径
//ry属性定义了垂直半径
  fill="yellow" stroke="purple" stroke-width="2" />
xmlns:xlink="https://xx.com">
<a xlink:href="https://xx.com" target="_blank">
<text x="50" y="105" fill="red"transform="rotate(30 20,40)">这里是line:</text>
  </a>
  <line x1="0" y1="160" x2="400" y2="160" 
  style="stroke:rgb(255,0,0);stroke-width:2" />
//x1属性定义x轴上行的开始
//y1属性定义y轴上行的开始
//x2属性定义x轴上的行的末尾
//y2属性定义了y轴上行的末尾
  <ellipse cx="200" cy="300" rx="200" ry="30" 
  style="fill:purple" />
  <ellipse cx="180" cy="270" rx="170" ry="20" 
  style="fill:lime" />
  <ellipse cx="170" cy="245" rx="150" ry="15" 
  style="fill:yellow" />
  <line x1="400" y1="0" x2="400" y2="400" 
  style="stroke:rgb(255,0,0);stroke-width:2" />
  <line x1="0" y1="0" x2="0" y2="400" 
  style="stroke:rgb(255,0,0);stroke-width:2" />
  <line x1="0" y1="0" x2="400" y2="0" 
  style="stroke:rgb(255,0,0);stroke-width:2" />
  <line x1="0" y1="400" x2="400" y2="400" 
  style="stroke:rgb(255,0,0);stroke-width:2" />
</svg>
xmlns:xlink="https://example.com"> 这里是line: //x1属性定义x轴上行的开始 //y1属性定义y轴上行的开始 //x2属性定义x轴上的行的末尾 //y2属性定义了y轴上行的末尾

多边型:

<svg height="400" width="400">
  <polyline points="0,0 400,0 400,400 0,400 0,0 100,0 100,30 0,30"
  fill="none" stroke="red" stroke-width="4" />
  <text x="5" y="20" fill="red">画个五角星:</text>
  <polygon points="100,100 40,278 190,168 10,168 160,278"
  style="fill:lime;stroke:red;stroke-width:3;fill-rule:evenodd;" />
  <line x1="200" y1="0" x2="200" y2="400" 
  style="stroke:rgb(255,0,0);stroke-width:2" />
  <polygon points="300,100 240,278 390,168 210,168 360,278" 
  style="fill:lime;stroke:purple;stroke-width:1" />
</svg>
画个五角星:

系列:note

该系列自动来自分类: note

  1. macOS 外置硬盘为什么会出现 ._* 文件
  2. 小众工具软件应该免费、买断还是订阅
  3. 用iPhone和iPad维护Git静态网站可行吗
  4. 一个Mac截图工具,从能截图到能上架还差多远
  5. 重复文件清理工具最危险的不是漏扫,而是误删
  6. 备份dokuwiki数据
  7. grep 命令
  8. zola的Front Matter完整字段的意思
  9. 从dokuwiki切换到quartz
  10. 安装immich记录
  11. 修改dokuwiki时区
  12. macos安装dokuwiki
  13. Debian创建新用户和设置防火墙
  14. mac在Debian安装wireguard和使用
  15. 再也不买不能解bl的手机了
  16. Firefox设置
  17. debian安装FFmpeg来合并youtube音频
  18. css 扩散列表
  19. 两个练习
  20. css RWD
  21. css 图片
  22. css 提示
  23. css 下拉
  24. css 表单
  25. css 导航栏
  26. css 单词
  27. HTML SVG (当前)
  28. HTML Canvas
  29. HTML input
  30. HTML 结构
  31. 电气施工图说明
  32. china uses dropbox
  33. Nginx installs SSL certificates
  34. debian install shadowsocks
  35. Visual studio code set the python environment
  36. install hexo

下一篇推荐

系列继续阅读

HTML Canvas