d3 svg悬停效果_SVG的形状悬停效果

本文介绍了如何使用SVG和Snap.svg库创建形状悬停效果,包括如何在悬停时通过改变路径实现形状变形。通过在矢量图形编辑器中绘制形状,然后在HTML中插入SVG元素,利用CSS和JavaScript实现悬停时的动态变换。文中提供了三个不同示例,并强调了SVG在调整大小和响应式设计中的优势。
摘要由CSDN通过智能技术生成
d3 svg悬停效果

d3 svg悬停效果

ShapeHoverEffect

If you have visited the fantastic new edition of The Christmas Experiments then you might have noticed the really cool hover effect in the Christmas calendar that uses a triangular shape. The shape is made up of a triangle using borders and today I would like to show you how to achieve the same effect using SVG and Snap.svg. The idea is to create a SVG with one path that represents the shape background for some caption and to morph that path into another one on hover. There are many creative possibilities and today we’ll create three different examples. The nice thing of utilizing SVG is that we can adjust the shape size to their parent container’s size and make everything fluid.

如果您访问了神奇的新版《圣诞节实验》,那么您可能已经注意到圣诞节日历中使用三角形的悬停效果了。 该形状由带边框的三角形组成,今天我想向您展示如何使用SVG和Snap.svg达到相同的效果。 这个想法是用一条路径代表一个字幕的形状背景创建一个SVG,然后在悬停时将该路径变形为另一条路径。 有许多创造性的可能性,今天我们将创建三个不同的示例。 利用SVG的好处是,我们可以将形状大小调整为其父容器的大小,并使所有内容流畅。

The illustrations used in the demos are by talented Isaac Montemayor. See his original artwork on his website or Dribbble.

演示中使用的插图由才华横溢的艾萨克·蒙特马约尔( Isaac Montemayor)制作 在他的网站Dribbble上查看他的原始作品。

So, let’s get started!

所以,让我们开始吧!

标记 (The Markup)

What we’ll do first, is to draw two shapes in a vector graphics editor like Adobe Illustrator or Inkscape. Each shape will consist of one path and when we are done, we’ll copy the points of our paths to be used in our markup. Note that we’ve transformed a polygon into a path. If you are using Inkscape you can do that by selecting the object and choosing Path > Object to Path. The points for the path can be obtained from Edit > XML Editor… which will open a view as seen in the following screenshot:

我们首先要做的是在矢量图形编辑器(如Adobe Illustrator或Inkscape)中绘制两个形状。 每种形状都将包含一个路径,完成后,我们将复制路径的点以用于标记。 请注意,我们已经将多边形转换为路径。 如果使用的是Inkscape,则可以通过选择对象并选择“路径”>“对象到路径”来实现。 路径的点可以从“编辑”>“ XML编辑器...”中获取

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值