如何从圆角矩形的顶部中心描边
How to stroke from top-center of rounded rectangle
我想用 SVG 制作一个按钮并复制 YouTube 的自动播放圈。我一直试图让笔划在顶部中心开始和结束,但它最好从左上角开始,因为当我开始更改 stroke-dasharry 和 stroke-dashoffset 周围的数字时,它开始消失开始或结束。我知道用圆圈会容易得多,但我想看看这是否可能。它开始似乎不是。
svg:hover {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
<svg width="160" height="80">
<a xlink:href="/next_video" target="_self">
<rect class="path" height="70" width="130" y="5" x="5" rx="35" stroke="#eee" stroke-width="8px" />
<rect height="60" width="120" y="10" x="10" rx="30" fill="#00a6bc" />
<text fill="#eee" text-anchor="middle" y="45" x="70">Next video</text>
</a>
</svg>
我不知道我是否可以用 SVG 轻松地做到这一点,但我知道我可以用 div
s 和伪元素包裹在一些好的时尚 CSS !
http://codepen.io/anon/pen/WxROry
<div class="cont">
<div class="rekt"><div class="rekt2"><span>Next Video</span></div></div>
</div>
这是HTML。对于CSS,只需点击link;它比适当的要长一点。
无法更改 SVG 破折号的起始位置 <rect>
。
要实现您想要的效果,您需要切换到 <path>
元素并自己绘制其形状。然后你可以从任何你想开始的路径。
svg:hover {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
<svg width="160" height="80">
<a xlink:href="/next_video" target="_self">
<path d="M70,5 L100,5 A35,35 0 0 1 100,75 L40,75 A35,35 0 0 1 40,5 Z"
stroke="#eee" stroke-width="8px" />
<rect height="60" width="120" y="10" x="10" rx="30" fill="#00a6bc" />
<text fill="#eee" text-anchor="middle" y="45" x="70">Next video</text>
</a>
</svg>
我想用 SVG 制作一个按钮并复制 YouTube 的自动播放圈。我一直试图让笔划在顶部中心开始和结束,但它最好从左上角开始,因为当我开始更改 stroke-dasharry 和 stroke-dashoffset 周围的数字时,它开始消失开始或结束。我知道用圆圈会容易得多,但我想看看这是否可能。它开始似乎不是。
svg:hover {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
<svg width="160" height="80">
<a xlink:href="/next_video" target="_self">
<rect class="path" height="70" width="130" y="5" x="5" rx="35" stroke="#eee" stroke-width="8px" />
<rect height="60" width="120" y="10" x="10" rx="30" fill="#00a6bc" />
<text fill="#eee" text-anchor="middle" y="45" x="70">Next video</text>
</a>
</svg>
我不知道我是否可以用 SVG 轻松地做到这一点,但我知道我可以用 div
s 和伪元素包裹在一些好的时尚 CSS !
http://codepen.io/anon/pen/WxROry
<div class="cont">
<div class="rekt"><div class="rekt2"><span>Next Video</span></div></div>
</div>
这是HTML。对于CSS,只需点击link;它比适当的要长一点。
无法更改 SVG 破折号的起始位置 <rect>
。
要实现您想要的效果,您需要切换到 <path>
元素并自己绘制其形状。然后你可以从任何你想开始的路径。
svg:hover {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
<svg width="160" height="80">
<a xlink:href="/next_video" target="_self">
<path d="M70,5 L100,5 A35,35 0 0 1 100,75 L40,75 A35,35 0 0 1 40,5 Z"
stroke="#eee" stroke-width="8px" />
<rect height="60" width="120" y="10" x="10" rx="30" fill="#00a6bc" />
<text fill="#eee" text-anchor="middle" y="45" x="70">Next video</text>
</a>
</svg>