SVG的text使用:

参考:http://www.docin.com/p-7393979.html

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Title</title>
</head>
<body>
<div>
<svg width="240px" height="240px" xmlns="http://www.w3.org/2000/svg">
<path d="M20,10,20,120M10,30,100,30,M10,70,100,70M10,110,100,110" style="stroke:gray;" />
<text x=20 y=30>Simplest Text</text>
<text x=20 y=70 style="stroke:black">Outlined/filled</text>
<text x=20 y=110 style="stroke:black;stroke-width:0.5;fill:none">Outlined only</text>
</svg>
<svg width="240px" height="240px" xmlns="http://www.w3.org/2000/svg">
<g style="font-size:18pt" >
<text x=20 y=20 style="font-weight:bold">bold</text>
<text x=120 y=20 style="font-style:italic">italic</text>
<text x=20 y=60 style="text-decoration:underline">under</text>
<text x=80 y=60 style="text-decoration:overline">over</text>
<text x=140 y=60 style="text-decoration:line-through">through</text>
<!-- word-spacing:10pt导致word之间的距离变大了 -->
<text x=20 y=100 style="word-spacing:10pt">abc def</text>
<!-- word-spacing:-3pt导致word之间的距离变小了 -->
<text x=140 y=100 style="word-spacing:-3pt">abc def</text>
<!-- letter-spacing:5pt导致letter之间的距离变大了 -->
<text x=20 y=140 style="letter-spacing:5pt">abc def</text>
<!-- letter-spacing:-6pt导致letter之间的距离变小了 -->
<text x=140 y=140 style="letter-spacing:-6pt">abc def</text>
</g>
</svg>
<svg width="240px" height="240px" xmlns="http://www.w3.org/2000/svg">
<g style="font-size:14pt">
<path d="M100,10,100,100" style="stroke:gray;fill:none" />
<!-- 文本水平对齐的方式三种:start,middle,end -->
<text x=100 y=20 style="text-anchor:start">start</text>
<text x=100 y=40 style="text-anchor:middle">middle</text>
<text x=100 y=60 style="text-anchor:end">end</text>
</g>
</svg>
<svg width="440px" height="240px" xmlns="http://www.w3.org/2000/svg">
<!-- tspan 可以进行text标签内的字体的装饰 -->
<text x=10 y=30 style="font-size:12pt" >Swith among
<tspan style="font-style:italic">italic</tspan>,normal and
<tspan style="font-style:bold">bold</tspan> text.
</text>
<!-- 在有tspan的情况下,使用line-through会穿过每一个tspan的; -->
<text x=10 y=50 style="text-decoration:line-through" >F<tspan dy=4>a</tspan><tspan dy=4>l</tspan><tspan dy=4>l</tspan></text>
<!-- 注意后面的文字,会受到前面tspan的位置信息的影响 -->
<text x=10 y=90>It's <tspan dx="0 4 -3 5 -4 6" dy="0 -3 7 3 -2 -8" rotate="5 10 -5 -20 0 15">shaken</tspan>,not stirred.</text>
<text x=10 y=130>C<tspan style="baseline-shift:sub">12</tspan> and 10<tspan style="baseline-shift:super">23</tspan></text>
</svg>
</div>
<div>
<svg width="240px" height="240px" xmlns="http://www.w3.org/2000/svg">
<!-- 通过旋转将字体变为纵向 -->
<text x=10 y=20 transform="rotate(90,10,20)">Rotated 90</text>
<!-- 使用writing-mode:tb将字体变为纵向 -->
<text x=40 y=20 style="writing-mode:tb;">mode:tb</text>
<!-- 可以使用glyph-orientation-vertical:0将字母变为垂直方向;其值只能是90的倍数 -->
<text x=70 y=20 style="writing-mode:tb;glyph-orientation-vertical:0">mode:tb</text>
<!-- 可以使用letter-spacing:-3pt缩小字母之间的距离 -->
<text x=100 y=20 style="writing-mode:tb;glyph-orientation-vertical:0;letter-spacing:-3pt">mode:tb</text>
</svg>
<svg width="240px" height="240px" xmlns="http://www.w3.org/2000/svg">
<!-- 文本是水平的时候可以使用glyph-orientation-horizontal:90将字母方向旋转,其值只能是90的倍数 -->
<text x=10 y=20 style="glyph-orientation-horizontal:90">this is text</text>
</svg>
</div>
</body>
</html>

SVG的text使用的更多相关文章

  1. SVG animation(text, background)

    SVG animation(text, background) demo https://www.happyelements.com/ LICEcap bug Giphy 低帧率 gif https: ...

  2. how to get svg text tspan x,y position value in js

    how to get svg text tspan x,y position value in js <svg xmlns="http://www.w3.org/2000/svg&qu ...

  3. HTML中的SVG

    HTML5中的SVG是Scalable Vector Graphic的简称,是一种用来绘制矢量图的HTML5标签,由万维网联盟定制,是一个基于可扩展标记语言,用于绘制二维可缩放矢量图形. 是一种使用X ...

  4. svg + d3

    为了实现元素的添加,删除,拖拽,左键点击,右键单击,悬浮等功能,使用了d3 + svg 的技术来实现界面. 最开始是采用canvas,但是由于功能原因放弃了该技术,可以看下 canvas简介 另附:c ...

  5. D3+svg 案例

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  6. 基于SVG的web页面图形绘制API介绍

    转自:http://blog.csdn.net/jia20003/article/details/9185449 一:什么是SVG SVG是1999由W3C发布的2D图形描述语言,纯基于XML格式的标 ...

  7. SVG 2D入门8 - 文档结构

    前面介绍了很多的基本元素,包括结构相关的组合和重用元素,这里先对SVG的文档结构中剩下的相关元素简单总结一下,然后继续向前领略SVG的其他特性. SVG文档的元素基本可以分为以下几类: 动画元素:an ...

  8. 超级强大的SVG SMIL animation动画详解

    本文花费精力惊人,具有先驱前瞻性,转载规则以及申明见文末,当心予以追究.本文地址:http://www.zhangxinxu.com/wordpress/?p=4333 //zxx: 本文的SVG在有 ...

  9. SVG彩虹字

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

随机推荐

  1. FZU Problem 2029 买票问题(树状数组)

    当我看到题目是5秒的时候,压根没有想树状数组,一直奔着模拟队列去想了,最后也没搞定,赛后看到大神的题解才恍然大悟,原来如此,题目中有明显的暗示,求前n项和,骤然感叹,自己太low... 果然还是要多做 ...

  2. Android音频系统之AudioFlinger(一)

    1.1 AudioFlinger 在上面的框架图中,我们可以看到AudioFlinger(下面简称AF)是整个音频系统的核心与难点.作为Android系统中的音频中枢,它同时也是一个系统服务,启到承上 ...

  3. eclipse proxy

    -Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.ht ...

  4. ActiveMQ讯息传送机制以及ACK机制

    http://blog.csdn.net/lulongzhou_llz/article/details/42270113 ActiveMQ消息传送机制以及ACK机制详解 AcitveMQ是作为一种消息 ...

  5. C程序编译执行过程

    C程序编译执行过程   认识C编译执行过程,是C学习的开端. 简单说C语言从编码编译到执行要经历一下过程:   C源代码 编译---->形成目标代码,目标代码是在目标机器上运行的代码. 连接-- ...

  6. iOS10适配——相机,通讯录,麦克风等权限设置

    崩溃:[access] This app has crashed because it attempted to access privacy-sensitive data without a usa ...

  7. (简单) POJ 3279 Fliptile,集合枚举。

    Description Farmer John knows that an intellectually satisfied cow is a happy cow who will give more ...

  8. HTML学习(五)链接

    1.创建文本链接 <html> <body> <p> <a href="/index.html">本文本</a> 是一个 ...

  9. net stop 出现1060错误

    net stop时出现1060错误,答案: 原来,net stop后面不能想当然地加上服务,而要在‘服务’里看看,那个服务究竟叫什么名字. 比如,我的mysql安装时不叫mysql,而是mysql5 ...

  10. 升级apache

    升级Apache到最新版本,本来并不复杂,但是因为涉及到不能停止现有的Apache实例的运行,因此要小心翼翼的做. 大致分成三步: 编译新的Apache, 配置新的Apache, 替换旧的Apache ...