一、stroke属性介绍

SVG提供了一个范围广泛stroke属性,用于描述轮廓,其中包括

  • stroke 指定颜色
  • stroke-width 指定宽度
  • stroke-linecap 指定端点样式
  • stroke-dasharray 指定间隔线数组

1.所有的stroke属性,可应用于任何类的线条、文字和元素就像一个圆的轮廓

2.所有的stroke属性,可以单独指定,可以都放在style属性中。

二、stroke属性定义一条线、文本或元素的轮廓颜色,stroke-width属性定义一条线、文本或元素轮廓厚度

  1. <svg style="border:1px solid red;" width="400px" height="300px">
  2. <g fill='none'>
  3. <path stroke="red" stroke-width="5" d="M20 20,300 20 " />
  4. <path stroke="blue" stroke-width="5" d="M20 120,300 120" />
  5. <path stroke="black" stroke-width="5" d="M20 220,300 220"/>
  6. </g>
  7. </svg>

三、stroke-linecap属性定义不同类型的开放路径的终结

  1. <svg style="border:1px solid red;" width="400px" height="300px">
  2. <g fill='none' stroke-width="10">
  3. <path stroke="red" stroke-linecap="round" d="M20 20,300 20 " />
  4. <path stroke="blue" stroke-linecap="butt" d="M20 120,300 120" />
  5. <path stroke="black" stroke-linecap="square" d="M20 220,300 220"/>
  6. </g>
  7. </svg>

四、stroke-dasharray属性用于创建虚线

  1. <svg style="border:1px solid red;" width="500px" height="100px">
  2. <g fill='none' stroke='black' stroke-width='4'>
  3. <path stroke-dasharray='5,5' d='M5 20,400,20' />
  4. <path stroke-dasharray='10,10' d='M5 40,400,40' />
  5. <path stroke-dasharray='20,10,5,5,5,10' d='M5 60,400,60' />
  6. </g>
  7. </svg>

示例1,使用stroke描述文字轮廓

  1. <svg style="border:1px solid red;" width="400px" height="400px">
  2. <text x='100' y='100' fill='red' style='font-size:50px;font-weight:bold;font-family:楷体'
  3. stroke='blue' stroke-width='2'
  4. >中文内容</text>
  5. </svg>

示例2,在style中使用stroke属性

  1. <svg style="border:1px solid red;" width="200px" height="400px">
  2. <rect style="stroke:blue;stroke-width:5px;stroke-dasharray:2 10 2"
  3. width='100' height='100' x='50' y='50'></rect>
  4.  
  5. <rect style="stroke:blue;stroke-width:3px;"
  6. stroke-dasharray='2,10,2' fill='green'
  7. width='100' height='100' x='50' y='200'></rect>
  8. </svg>

SVG Stroke属性的更多相关文章

  1. 学习SVG系列(3):SVG Stroke属性

    SVG stroke 属性 1.stroke 2.stroke-width 3.stroke-linecap 4.stroke-dasharray 5.stroke-opacity 6.stroke- ...

  2. SVG 学习<二>进阶 SVG世界,视野,视窗 stroke属性 svg分组

    目录 SVG 学习<一>基础图形及线段 SVG 学习<二>进阶 SVG世界,视野,视窗 stroke属性 svg分组 SVG 学习<三>渐变 SVG 学习<四 ...

  3. svg & stroke & style & class

    svg & stroke & style & class svg selected style methods style class, !important fill, st ...

  4. SVG(可扩展矢量图)系列教程

    本系列教程同步至博客www.waylau.com 从新往久排序,持续更新 SVG与JS交互实例之画板 SVG <marker>创建箭头 SVG实例之中国地图 SVG实例之电力开关 SVG ...

  5. 学习SVG 重点汇总

    什么是SVG? Δ  SVG 指可伸缩矢量图形 (Scalable Vector Graphics) Δ  SVG 用来定义用于网络的基于矢量的图形 Δ  SVG使用XML格式来定义图形 Δ  SVG ...

  6. SVG 使用marker画箭头(一)

    一.使用Marker画箭头 1.定义一个箭头的marker引用 <defs> <marker id='markerArrow' markerWidth='13' markerHeig ...

  7. SVG Path路径使用(一)

    一.<path> 标签 <path> 标签用来定义路径. 下面的命令可用于路径数据: M = moveto L = lineto H = horizontal lineto V ...

  8. Svg.Js 父类的基础操作

    一.SVG.Doc 创建SVG文档 var draw = SVG('drawing') <div id="svg1"></div> <script&g ...

  9. Svg.Js A标签,链接操作

    一.创建a标签,为a标签添加内容 <div id="svg1"></div> <script> //SVG.A 链接创建 var draw = ...

随机推荐

  1. AIM Tech Round 4 (Div. 1) C - Upgrading Tree 构造 + 树的重心

    C - Upgrading Tree 我发现我构造题好弱啊啊啊. 很明显能想到先找到重心, 然后我们的目标就是把所有点接到重心的儿子上,让重心的儿子子树变成菊花图, 这个先把重心到儿子的边连到 i , ...

  2. PHP实现数据分页显示

    分页在后台管理中是经常使用的功能,分页显示方便大量数据的管理. 实例代码如下: <!DOCTYPE html> <html> <head> <meta cha ...

  3. MySQL连接表

    一:MySQL别名 1.介绍 使用MySQL别名来提高查询的可读性. MySQL支持两种别名,称为列别名和表别名. 有时,列的名称是一些表达式,使查询的输出很难理解.要给列一个描述性名称,可以使用列别 ...

  4. Docker化高可用redis集群

    最近遇到部分系统因为redis服务挂掉,导致部分服务不可用.所以希望搭建一个redis集群镜像,把原先散落各处的redis服务器统一管理起来,并且保障高可用和故障自动迁移. 一:redis集群分类 大 ...

  5. BZOJ4227 : 城市

    首先一遍Dijkstra求出S到每个点的最短路,并建出最短路图. 那么对于一条边,求在这条边不能使用的情况下,到首都S的最短时间会变长的点的数目,等价于求去掉这条边后在最短路图中不能从S出发到达的点的 ...

  6. BZOJ2944 : [Poi2000]代码

    对于根,要让它的排名尽量小,也就是要让右子树的点数尽量多. 于是从大到小枚举右子树的点数,用Catalan数计算方案数,直到找到相应的右子树的点数为止. 此时根的排名已经确定,接下来要让左子树的代码的 ...

  7. Develop with asyncio部分的翻译

    Develop with asyncio 异步程序和普通的连续程序(也就是同步程序)是很不一样的,这里会列出一些常见的陷阱,并介绍如何去避开他们. Debug mode of asyncio 我们用a ...

  8. HNOI 越狱

    题目描述 监狱有连续编号为 1…N的 N 个房间,每个房间关押一个犯人,有 M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱. 输入输出格式 ...

  9. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) E. Goods transportation 动态规划

    E. Goods transportation 题目连接: http://codeforces.com/contest/724/problem/E Description There are n ci ...

  10. BZOJ 4610: [Wf2016]Ceiling Functi 水题

    4610: [Wf2016]Ceiling Functi 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4610 Description ...