gsap+svg实现动态水滴填充tabbar导航条效果代码

代码语言:html

所属分类:菜单导航

代码描述:gsap+svg实现动态水滴填充tabbar导航条效果代码

代码标签: 水滴 填充 tabbar 导航 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

 
<meta charset="UTF-8">


 
 
<style>
#tabbar {
 
--c-color: #763FEE;
 
--c-background: #FFFFFF;
 
--indicator-x: 34px;
 
--indicator-circle-o: 1;
 
--indicator-circle-y: 0px;
 
-webkit-tap-highlight-color: transparent;
 
border-radius: 31px;
 
overflow: hidden;
 
position: relative;
 
background: var(--c-background);
}
#tabbar .indicator {
 
position: absolute;
 
z-index: 1;
 
left: 0;
 
bottom: 0;
 
display: block;
 
width: 68px;
 
height: 72px;
 
fill: var(--c-color);
 
transform: translateX(var(--indicator-x));
}
#tabbar .indicator path {
 
transform: translateY(2px);
}
#tabbar .indicator circle {
 
opacity: var(--indicator-circle-o);
 
transform: translateY(var(--indicator-circle-y)) translateZ(0);
}
#tabbar ul {
 
padding: 0;
 
margin: 0;
 
list-style: none;
 
width: 375px;
 
height: 100px;
 
display: flex;
 
justify-content: center;
 
align-items: center;
 
position: relative;
 
z-index: 1;
}
#tabbar ul li {
 
--icon-y: 0px;
 
--icon-s: 1;
 
--icon-circle: 0px;
}
#tabbar ul li:not(:first-child) {
 
margin-left: 26px;
}
#tabbar ul li:not(:last-child) {
 
margin-right: 26px;
}
#tabbar ul li.active {
 
--icon-circle: 28px;
}
#tabbar ul li button {
 
display: block;
 
width: 28px;
 
height: 28px;
 
padding: 0;
 
margin: 0;
 
cursor: pointer;
 
outline: none;
 
background: none;
 
border: none;
 
position: relative;
 
-webkit-appearance: none;
 
transform: translateY(var(--icon-y)) scale(var(--icon-s)) translateZ(0);
}
#tabbar ul li button:before {
 
content: "";
 
position: absolute;
 
z-index: 1;
 
left: 0;
 
top: 0;
 
right: 0;
 
bottom: 0;
 
border-radius: 50%;
 
background: var(--c-background);
 
-webkit-clip-path: circle(var(--icon-circle) at 50% 100%);
         
clip-path: circle(var(--icon-circle) at 50% 100%);
}
#tabbar ul li button svg {
 
color: var(--c-color);
 
display: block;
 
overflow: visible;
 
width: 28px;
 
height: 28px;
}
#tabbar ul li button svg:last-child {
 
position: absolute;
 
z-index: 2;
 
top: 0;
 
left: 0;
 
-webkit-clip-path: circle(var(--icon-circle) at 50% 100%);
         
clip-path: circle(var(--icon-circle) at 50% 100%);
}

html
{
 
box-sizing: border-box;
 
-webkit-font-smoothing: antialiased;
}

* {
 
box-sizing: inherit;
}
*:before, *:after {
 
box-sizing: inherit;
}

body
{
 
font-family: "Poppins", Arial;
 
min-height: 100vh;
 
display: flex;
 
justify-content: center;
 
align-items: center;
 
background: #F4EEFD;
}
body
.dribbble {
 
position: fixed;
 
display: block;
 
right: 20px;
 
bottom: 20px;
}
body
.dribbble img {
 
display: block;
 
height: 28px;
}
body
.twitter {
 
position: fixed;
 
display: block;
 
right: 64px;
 
bottom: 14px;
}
body
.twitter svg {
 
width: 32px;
 
height: 32px;
 
fill: #1da1f2;
}
</style>



</head>

<body>
 
<div id="tabbar">
   
<ul>
       
<li class="active">
           
<button>
               
<svg>
                   
<use xlink:href="#icon-home" />
               
</svg>
               
<svg>
                   
<use xlink:href="#icon-home-filled" />
               
</svg>
           
</button>
       
</li>
       
<li>
           
<button>
               
<svg>
                   
<use xlink:href="#icon-chat" />
               
</svg>
               
<svg>
                   
<use xlink:href="#icon-chat-filled" />
               
</svg>
           
</button>
       
</li>
       
<li>
           
<button>
               
<svg>
                   
<use xlink:href="#icon-folder" />
               
</svg>
               
<svg>
                   
<use xlink:href="#icon-folder-filled" />
               
</svg>
           
</button>
       
</li>
       
<li>
           
<button>
               
<svg>
                   
<use xlink:href="#icon-user" />
               
</svg>
               
<svg>
                   
<use xlink:href="#icon-user-filled" />
               
</svg>
           
</button>
       
</li>
   
</ul>
   
<svg class="indicator" viewBox="0 0 68 72">
       
<defs>
           
<filter id="goo" x="-50%" width="200%" y="-50%" height="200%" color-interpolation-filters="sRGB">
               
<feGaussianBlur in="SourceGraphic" stdDeviation="1" result="blur" />
               
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 21 -7" result="cm" />
           
</filter>
       
</defs>
       
<g filter="url(#goo)">
           
<path d="M34 54C45.4078 54 48.3887 66.7534 68 72H0C19.6113 66.7534 22.5922 54 34 54Z" />
           
<circle cx="34" cy="66" r="4" />
       
</g>
   
</svg>
</div>

<svg style="display: none;" xmlns="http://www.w3.org/2000/svg" version="1.1">
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0