lengthAdjust属性用于决定在textLength属性定义的长度内文本的拉伸。使用此属性的元素是<text>,<textPath>,<tref>和<tspan>。
用法:
lengthAdjust = spacing | spacingAndGlyphs
属性值:lengthAdjust属性接受上面提到的和下面描述的值。
- 间距:它将调整字形之间的间距,但不会拉伸或挤压字形本身。
- intervalAndGlyphs:它将同时调整字形之间的间距和字形大小。
注意:lengthAdjust属性的默认值是间距。
下面的示例说明lengthAdjust属性的用法。
范例1:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.geek {
font-style:italic;
font-weight:bold;
}
</style>
</head>
<body>
<h1 style="color:green;
margin-left:35px;
font-size:25px;">
GeeksforGeeks
</h1>
<svg xmlns="http://www.w3.org/2000/svg">
<g>
<text class="geek" x="0" y="15">
Stretched with spacing only:-
</text>
<text x="0" y="35" textLength="300"
lengthAdjust="spacing">
A Computer Science
portal for geeks.
</text>
</g>
</svg>
</body>
</html>
输出:
范例2:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.geek {
font-style:italic;
font-weight:bold;
}
</style>
</head>
<body>
<h1 style="color:green;
margin-left:35px;
font-size:25px;">
GeeksforGeeks
</h1>
<svg xmlns="http://www.w3.org/2000/svg">
<g>
<text class="geek" x="0" y="15">
Stretched with spacing
and glyphs:-
</text>
<text x="0" y="35" textLength="300"
lengthAdjust="spacingAndGlyphs">
A Computer Science
portal for geeks.
</text>
</g>
</svg>
</body>
</html>
输出:
范例3:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.geek {
font-style:italic;
font-weight:bold;
}
</style>
</head>
<body>
<h1 style="color:green;
margin-left:35px;
font-size:25px;">
GeeksforGeeks
</h1>
<svg xmlns="http://www.w3.org/2000/svg">
<g>
<text class="geek" x="0" y="15">
Shrunk with spacing only:-
</text>
<text x="0" y="35" textLength="100"
lengthAdjust="spacing">
A Computer Science
portal for geeks.
</text>
</g>
</svg>
</body>
</html>
输出:
范例4:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.geek {
font-style:italic;
font-weight:bold;
}
</style>
</head>
<body>
<h1 style="color:green;
margin-left:35px;
font-size:25px;">
GeeksforGeeks
</h1>
<svg xmlns="http://www.w3.org/2000/svg">
<g>
<text class="geek" x="0" y="15">
Shrunk with spacing
and glyphs:-
</text>
<text x="0" y="35" textLength="100"
lengthAdjust="spacingAndGlyphs">
A Computer Science
portal for geeks.
</text>
</g>
</svg>
</body>
</html>
输出:
相关用法
- SVG viewBox属性用法及代码示例
- SVG rx属性用法及代码示例
- SVG width属性用法及代码示例
- SVG opacity属性用法及代码示例
- SVG stroke-width属性用法及代码示例
- SVG stroke属性用法及代码示例
- SVG height属性用法及代码示例
- SVG ry属性用法及代码示例
- SVG fill属性用法及代码示例
- SVG font-size属性用法及代码示例
- SVG stroke-dasharray属性用法及代码示例
- SVG cx属性用法及代码示例
- SVG flood-opacity属性用法及代码示例
- SVG filter属性用法及代码示例
- SVG font-style属性用法及代码示例
- SVG flood-color属性用法及代码示例
- SVG fill-opacity属性用法及代码示例
注:本文由纯净天空筛选整理自thacker_shahid大神的英文原创作品 SVG lengthAdjust Attribute。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。