我需要对文字进行斜切。每当svg行移动到文本上方时,文本应该被对角切割。 是否有可能实现这种情况。 ? 下面是代码。 以及我要实现的目标的形象。
<!DOCTYPE html>
<html>
<head><title></title>
<style type="text/css">
h1{
position: absolute;
top:0;
left: 10px;
}
</style>
</head>
<body>
<svg height="210" width="500">
<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
<line x1="150" y1="150" x2="200" y2="200" style="stroke:rgb(0, 0, 153);stroke-width:2">
<animateTransform attributeName="transform"
type="translate"
values="200 200;-150 -150;200 200"
begin="0s"
dur="5s"
repeatCount="indefinite"
/>
</line>
</svg>
<h1>OUR<br>WORK</h1>
</body>
</html>
&#13;
答案 0 :(得分:1)
这是完全在SVG中的版本。
<html>
<head><title></title>
<style type="text/css">
h1{
position: absolute;
top:0;
left: 10px;
}
</style>
</head>
<body>
<svg height="210" width="500">
<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
<line x1="150" y1="150" x2="200" y2="200" style="stroke:rgb(0, 0, 153);stroke-width:2">
<animateTransform attributeName="transform"
type="translate"
values="200 200;-150 -150;200 200"
begin="0s"
dur="5s"
repeatCount="indefinite"
/>
</line>
<defs>
<clipPath id="clip1">
<polygon points="0, 0 200, 200, 0, 200"/>
</clipPath>
<clipPath id="clip2">
<polygon points="0, 0 200, 0, 200, 200"/>
</clipPath>
</defs>
<text x="0" y="42" font-size="33px" font-weight="bold" clip-path="url(#clip1)">OUR<tspan x="0" dy="36">WORK</text>
<text x="4" y="38" font-size="33px" font-weight="bold" clip-path="url(#clip2)">OUR<tspan x="4" dy="36">WORK</text>
</svg>
</body>
</html>