一、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. 电脑同时安装Python2和Python3以及virtualenvwrapper(转)

    电脑同时安装Python2和Python3以及virtualenvwrapper  https://www.jianshu.com/p/d22f19496e03   windows: 1 下载地址:P ...

  2. Django 浏览器打开警告Not Found: /favicon.ico (转)

    Django 浏览器打开警告Not Found: /favicon.ico     初学Django 执行python manage.py runserver 0.0.0.0:8000 urls.py ...

  3. 多线程学习笔记八之线程池ThreadPoolExecutor实现分析

    目录 简介 继承结构 实现分析 ThreadPoolExecutor类属性 线程池状态 构造方法 execute(Runnable command) addWorker(Runnable firstT ...

  4. 使用ApiPost模拟发送get、post、delete、put等http请求

    现在的模拟发送请求插件很多比如老外的postman等,但亲测咱们国内的 ApiPost 更好用一些,因为它不仅可以模拟发送get.post.delete.put请求,还可以导出文档,支持团队协作也是它 ...

  5. Android-Service和Thread

    Android-Service和Thread 学习自 郭霖的博客 服务是运行在主线程上的 可能在我们第一次接触到Service的时候都是对于 __服务是运行在主线程上的 __这一现象不太理解,但是事实 ...

  6. CSDN博客栏目设置个性化

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha ====== <a href=" http://weibo.com/23 ...

  7. 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem H. Password Service dp

    Problem H. Password Service 题目连接: http://www.codeforces.com/gym/100253 Description Startups are here ...

  8. Linux下Nginx的监控

    一.安装Nginx 使用源码编译安装,包括具体的编译参数信息. 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好. 安装make: yum -y install gcc automake ...

  9. Sed&awk笔记之sed篇(转)

    Sed是什么 <sed and awk>一书中(1.2 A Stream Editor)是这样解释的: Sed is a "non-interactive" strea ...

  10. javaDoc 注释规范

    Javadoc虽然是Sun公司为Java文档自动生成设计的,可以从程序源代码中抽取类.方法.成员等注释形成一个和源代码配套的API帮助文档.但是Javadoc的注释也符合C的注释格式,而且doxyen ...