一、stroke属性介绍

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

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

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

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

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

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

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

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

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

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

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

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

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

<svg style="border:1px solid red;" width="200px" height="400px">
<rect style="stroke:blue;stroke-width:5px;stroke-dasharray:2 10 2"
width='100' height='100' x='50' y='50'></rect> <rect style="stroke:blue;stroke-width:3px;"
stroke-dasharray='2,10,2' fill='green'
width='100' height='100' x='50' y='200'></rect>
</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. Codeforces 601C Kleofáš and the n-thlon 概率dp

    Kleofáš and the n-thlon 我们可以用dp算出比当前这个人得分少的概率, 然后人数乘概率就好啦. dp[ i ][ j ]表示进行了 i 轮 得分为 j 的概率, 因为每个人都是独 ...

  2. vue组件之间通信传值

    原文链接:https://blog.csdn.net/lander_xiong/article/details/79018737 我认为这位博主的这篇文章写的非常详细,通俗易懂, 我们这次的vue项目 ...

  3. django-QueryDict 对象

    在 HttpRequest 对象中,属性 GET 和 POST 得到的都是 django.http.QueryDict 所创建的实例.这是一个 django 自定义的类似字典的类,用来处理同一个键带多 ...

  4. BZOJ2278 : [Poi2011]Garbage

    如果两个环相交,那么相交的部分相当于没走. 因此一定存在一种方案,使得里面的环都不相交. 把不需要改变状态的边都去掉,剩下的图若存在奇点则无解. 否则,每找到一个环就将环上的边都删掉,时间复杂度$O( ...

  5. HTML5 的新特性以及新标签的浏览器兼容问题

    新特性: HTML5 现在已经不是 SGML 的子集,主要是关于图像,位置,存储,多任务等功能的增加. 1)  拖拽释放(Drag and drop) API 2)  语义化更好的内容标签(heade ...

  6. 马士兵hadoop第四课:Yarn和Map/Reduce配置启动和原理讲解

    马士兵hadoop第一课:虚拟机搭建和安装hadoop及启动 马士兵hadoop第二课:hdfs集群集中管理和hadoop文件操作 马士兵hadoop第三课:java开发hdfs 马士兵hadoop第 ...

  7. j.u.c系列(08)---之并发工具类:CountDownLatch

    写在前面 CountDownLatch所描述的是”在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待“:用给定的计数 初始化 CountDownLatch.由于调用了 countDo ...

  8. ant design Modal关闭时清除数据的解决方案

    背景:modal组件关闭时不清除数据,原来输入的数据还存在 解决方案: 1.modal的api:destroyOnClose 2.手动控制modal的销毁 this.state = { destroy ...

  9. linux 学习之路(学linux必看)

    很多同学接触Linux不多,对Linux平台的开发更是一无所知. 而现在的趋势越来越表明,作为一个优秀的软件开发人员,或计算机IT行业从业人员, 掌握Linux是一种很重要的谋生资源与手段. 下来我将 ...

  10. GitHub 第一坑:换行符自动转换

    源起 一直想在 GitHub 上发布项目.参与项目,但 Git 这货比较难学啊.买了一本<Git 权威指南>,翻了几页,妈呀,那叫一个复杂,又是 Cygwin 又是命令行的,吓得我不敢学了 ...