svg悬浮图形变形动画效果代码
代码语言:html
所属分类:悬停
代码描述:svg悬浮图形变形动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html> <head> <style> * { margin: 0; padding: 0; } #wrapper { overflow: hidden; width: 100%; height: 100vh; background: #383838; position: relative; } #svg1 { display: block; width: 100%; height: 100%; transform: scale(.9); position: absolute; bottom: -20px; z-index: 2; } #base { cursor: pointer; } #clip { transform: scale(1) rotate(0deg); transform-origin: 50% 50%; transition: all .8s linear; } #base:hover #clip { transform: scale(7) rotate(70deg); } /* info text with arrow, not important for Effect */ .info { color: #fff; position: absolute; top: 70%; width: 100%; text-align: center; font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 5vh; z-index: 1; } .info svg { width: 5vh; } </style> </head> <body> <div id="wrapper" ontouchstart=""> <svg id="svg1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 310.9 343.3"> <!-- when the hover is active, i use svg filter to set background Image for silhouette (change opacity in js for feFlood), otherwise when hover is inactive background is set to solid color --> <filter id="filter" primitiveUnits="objectBoundingBox"> <feImage id="bg" x="-69.00000000000044%" y="0%" height="100%" width="300%" preserveAspectRatio="xMinYMid slice" result="PHOTO" xlink:href="//repo.bfw.wiki/bfwrepo/image/5fb4a415bd3d5.png"></feImage> <feComposite operator="in" in="PHOTO" in2="SourceGraphic" result="mask"></feComposite> <feFlood id="feFlood" flood-color="rgb(13,157,197)" flood-opacity="1" result="flood"></feFlood> <feComposite operator="in" in="flood" in2="SourceGraphic" result="blue"></feComposite> <feMerge> <feMergeNode in="mask"></feMergeNode> <feMergeNode in="blue"></feMergeNode> </feMerge> </filter> <g id="base"> <!-- this is man silhouette svg element. I use Clip-Path to cut this Element in star shape and svg Filter to set background Image (which I animate on hover) --> <path clip-path="url(#clipPath)" filter="url(#filter)" d="M310.9,32.6S298,44.7,289.5,43.5c0,0,23.1-18.9,17.5-38.1,0,0-22.7,24.2-31.6,20.6,0,0-3.4-19.5-12.7-26,0,0-4.1,25.5-20.8,21.5,0,0,6.8-7,4.6-11.9,0,0-61.7,12.8-85.7,1.1-46.2-22.3-75.3,6.9-83,24.2,0,0-84.7,18-52.6,136.4,0,0,12.9,35.2.1,44.4l9.5-1.4s-6.4,16.6-12.2,16.9L35,22.........完整代码请登录后点击上方下载按钮下载查看
网友评论0