-
Notifications
You must be signed in to change notification settings - Fork 0
/
6-文本1-alignment-baseline.html
136 lines (101 loc) · 3.18 KB
/
6-文本1-alignment-baseline.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="svg270/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="svg270/themes/icon.css">
<script type="text/javascript" src="svg270/jquery.min.js"></script>
<script type="text/javascript" src="svg270/jquery.easyui.min.js"></script>
<script src="svg270/svg.min.js"></script>
<script src="svg270/svg.panzoom.js"></script>
<script src="svg270/svg.draggable.js"></script>
<link rel="stylesheet" type="text/css" href="svg270/svg.select.css">
<script src="svg270/svg.select.js"></script>
<script src="svg270/svg.resize.js"></script>
</head>
<style>
ul li{
margin-bottom: 20px;
cursor: pointer;
}
/*高亮效果*/
.highlight{
stroke:#1470FA;
}
</style>
<!--
神奇的文字签,文字位置居然默认不是左上角的点
https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/alignment-baseline
alignment-baseline 取值:
auto | baseline | before-edge | text-before-edge | middle
| central | after-edge | text-after-edge | ideographic
| alphabetic | hanging | mathematical | inherit
-->
<body>
<svg width="400" height="400" viewBox="0 0 400 400"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<!-- Anchors in action -->
<!-- hanging -->
<text alignment-baseline="before-edge"
x="60" y="10">A hanging</text>
<!-- middle -->
<text alignment-baseline="middle"
x="60" y="60">A middle</text>
<!-- baseline -->
<text alignment-baseline="baseline"
x="60" y="110">A baseline</text>
<!-- before-edge -->
<text alignment-baseline="before-edge"
x="60" y="160">A before-edge</text>
<!--啥也没写--->
<text x="60" y="210">A aaa</text>
<!-- 参考线 -->
<line x1="60" y1="10" x2="400" y2="10" style="stroke:rgb(255,0,0);stroke-width:2"></line>
<line x1="60" y1="60" x2="400" y2="60" style="stroke:rgb(255,0,0);stroke-width:2"></line>
<line x1="60" y1="110" x2="400" y2="110" style="stroke:rgb(255,0,0);stroke-width:2"></line>
<line x1="60" y1="160" x2="400" y2="160" style="stroke:rgb(255,0,0);stroke-width:2"></line>
<line x1="60" y1="210" x2="400" y2="210" style="stroke:rgb(255,0,0);stroke-width:2"></line>
<!-- 参考点 -->
<circle cx="60" cy="10" r="3" fill="red" />
<circle cx="60" cy="60" r="3" fill="red" />
<circle cx="60" cy="110" r="3" fill="red" />
<circle cx="60" cy="160" r="3" fill="red" />
<circle cx="60" cy="210" r="3" fill="red" />
<style><![CDATA[
text{
font: bold 36px Verdana, Helvetica, Arial, sans-serif;
}
]]></style>
</svg>
</body>
<script>
/**
* 加载图例
*/
function loadLegendByUrl(url,callback){
$.post(url, {}, function (data) {
if($.isFunction(callback)){
callback(data);
}
}, "text");
}
function createUUID(){
var x= 13*Math.floor(Math.random()*1000)+"-"+7*Math.floor(Math.random()*100);
return "id_"+x;
}
/**
* 生成随机颜色
*/
function getRandomColor(){
var x= getRandomInteger();
return "#"+x;
}
/**
* 生成随机数
*/
function getRandomInteger(){
var x= Math.floor(Math.random()*9)+""+Math.floor(Math.random()*9)+""+Math.floor(Math.random()*9);
return x;
}
</script>
</html>