当前位置:网站首页>How to use SVG to make text effects arranged along any path
How to use SVG to make text effects arranged along any path
2022-07-19 10:37:00 【InfoQ】
Preface
demotransformcsscssSVGSVGSVGSVG
Basic knowledge of
What is?
SVG
SVGRefers to scalable vector graphics (Scalable Vector Graphics), In the case of enlarging or changing the size, the graphic quality will not be lost .
SVGUseXMLFormat definition drawing , Used to define vector based graphics for networks .
SVGIs the standard of the World Wide Web Alliance , AndDOMandXSLAnd so on.W3CStandards are a whole .
<path> Path elements
<path><path><path>- M: Move the pen to the specified point x,y Instead of drawing .
- a: From current point to point x,y Draw an elliptical arc .
- z: Close the path by drawing a line from the current point to the first point .
viewBox
attribute
viewBox( View box )<svg><svg>ViewBoxSVGwidth:500px; height:500px; viewBox="0 0 50 20" View box (ViewBox)<svg>SVGSVGx="10" y="10" width="20" height="20"SVG50px50px100px100px<style>
.box {
width: 200px;
height: 200px;
}
</style>
<div class="box">
<svg viewBox="0 0 100 100">
<path d="M0, 50 a50, 50 0 1, 1 0, 1z"></path>
</svg>
<div>

Use
<textPath>
Let the text follow the path
<textpath><text>SVG<textPath>xlink:href="#xxx"IDxxx<path><textPath><text><style>
body {
background-color: #b0b0b0;
}
.box {
width: 200px;
height: 200px;
margin: 50px;
background-color: #fff;
}
</style>
<div class="box">
<svg viewBox="0 0 100 100">
<path d="M0,50 a50,50 0 1,1 0,1z" id="circle" ></path>
<text>
<textPath xlink:href="#circle"> This is the circular text generated around the path ~</textPath>
</text>
</svg>
<div>

- 1, The circular path is filled with default black .
- 2,
SVGActual width and height inherited from.boxThe box , Width and height200px, The overflow part of the text is hidden .
- 1, We can
<path>Elemental fill Set tofill: none;, such , The background of the circular path is transparent .
- 2, to
SVGSet upoverflow: visible;, such , beyondSVGPart of the text will not be hidden .
css.box svg {
overflow: visible;
}
.box path {
fill: none;
}

Create text effects along any path
<path> <style>
.box {
width: 200px;
height: 200px;
margin: 50px;
font-size: 12px;
letter-spacing: 2px;
}
.box svg {
overflow: visible;
}
.box path {
fill: none;
}
</style>
<div class="box">
<svg viewBox="0 0 100 100">
<path d="m36.04045,45.99612c0.72238,0 18.78177,-17.27891 34.67404,-2.30385c15.89227,14.97505 -2.06122,51.71385 -33.12338,49.40999c-31.06217,-2.30385 -51.39459,-47.6821 -23.94431,-74.17643c27.45028,-26.49433 76.46594,-21.1417 90.427,-2.34993c13.96106,18.79177 9.22214,37.08444 7.59483,52.18238c-1.62731,15.09794 5.01952,28.13002 23.57052,28.88256c18.551,0.75254 68.69884,1.13642 61.38299,-46.48421" fill-opacity="null" id="circle" ></path>
<linearGradient id="myLinearGradient" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="red"></stop>
<stop offset="15%" stop-color="orange"></stop>
<stop offset="30%" stop-color="yellow"></stop>
<stop offset="45%" stop-color="green"></stop>
<stop offset="60%" stop-color="cyan"></stop>
<stop offset="80%" stop-color="blue"></stop>
<stop offset="100%" stop-color="purple"></stop>
</linearGradient>
<text fill="url(#myLinearGradient)">
<textPath xlink:href="#circle"> How to use SVG Create text effects along any path ~ Let's review with the big ice ~</textPath>
</text>
</svg>
</div>

Postscript
SVG<path> Elements SVG<path> Elements 边栏推荐
- On the structural types of C language
- HCIA rip experiment 7.11
- 读已提交级别下 注解事务+分布式锁结合引起的事故--活动购买机会的错乱
- R language uses LM function to build linear regression model, and uses subset function to specify the subset of data set to build regression model (uses subset function to filter the data subset that
- 二分类学习推广到多分类学习
- 智能存储柜控制系统设计及仿真
- The select function of dplyr package in R language deletes the data columns in dataframe containing the specified string content (drop columns in dataframe)
- 欧拉角,轴角,四元数与旋转矩阵详解
- 2022 windows penetration test of "Cyberspace Security" of Hunan secondary vocational group (ultra detailed)
- 2022 Zhejiang secondary vocational group "Cyberspace Security" code information acquisition and analysis (full version)
猜你喜欢

发送阻塞,接收阻塞

如何使用SVG制作沿任意路径排布的文字效果

知其然,而知其所以然,JS 对象创建与继承

YARN环境中应用程序JAR包冲突问题的分析及解决

HCIA static comprehensive experiment report 7.10

Distinction between private key and public key -- Explanation of private key and public key

Smart Lang: VMware fixed virtual machine IP address

Quick completion guide of manipulator (zero five): resources related to manipulator

华为防火墙(NGFW)的双机热备

「百度一面」怒喷面试官!不就是树遍历时增加一个行号?
随机推荐
HCIA rip experiment 7.11
读已提交级别下 注解事务+分布式锁结合引起的事故--活动购买机会的错乱
智能存储柜控制系统设计及仿真
Idea display service port --service
HCIA 静态综合实验报告 7.10
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化点状条带图(dot strip plot)、设置add参数为mean_sd添加均值标准差竖线、设置error.plot
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、设置na.rm参数为FALSE之后包含缺失值的分组的统计量的结果为NA
HCIA static comprehensive experiment report 7.10
Secondary vocational network security - (2022 network security NC batch connection script) free script oh~~~
【牛客刷题】/*C语言实现字符串左旋*/
旋转矩阵(Rotate Matrix)的性质分析(转发)
电商销售数据分析与预测(日期数据统计、按天统计、按月统计)
Stream流
What is pytest? Automated testing is a must
opencv 画黑色矩形,并写上序号
如果是用mybatics去访问达梦数据库,相当于完全一样了?因为SQL语法没变。对吧?
R语言使用epiDisplay包的kap函数计算配对列联表的计算一致性的比例以及Kappa统计量的值、使用xtabs函数生成二维列联表
Studio 3T无限试用
R language uses the ordinal of epidisplay package or. The display function obtains the summary statistical information of the ordered logistic regression model (the odds ratio and its confidence inter
2022年全国最新消防设施操作员(中级消防设施操作员)模拟试题及答案