gsap+Draggable3实现可配置鼠标悬浮文字浮现动画效果代码
代码语言:html
所属分类:悬停
代码描述:gsap+Draggable3实现可配置鼠标悬浮文字浮现动画效果代码
代码标签: gsap Draggable 配置 鼠标 悬浮 文字 浮现 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url('//repo.bfw.wiki/bfwrepo/css/normalize.min.css') layer(normalize);
@layer normalize, base, demo;
@layer demo {
:root {
--bg: light-dark(white, black);
--bd-top: light-dark(hsl(0 0% 90%), hsl(0 0% 50%));
--bd-bottom: light-dark(hsl(0 0% 40% / 0.5), black);
--color: light-dark(hsl(0 0% 10%), hsl(0 0% 90%));
--tip: light-dark(
color-mix(in hsl, var(--bg), canvasText 5%),
color-mix(in hsl, var(--bg), canvasText 25%)
);
--tip-height: 2rem;
--ease-in: linear(
0 0%,
0.0039 6.25%,
0.0156 12.5%,
0.0352 18.75%,
0.0625 25%,
0.0977 31.25%,
0.1407 37.5%,
0.1914 43.74%,
0.2499 49.99%,
0.3164 56.25%,
0.3906 62.5%,
0.5625 75%,
0.7656 87.5%,
1 100%
);
--ease: ease;
}
.nav li {
width: 40px;
height: 40px;
border-radius: 50%;
display: grid;
place-items: center;
position: relative;
&::after {
content: '';
position: absolute;
inset: -1px 0;
}
}
.nav {
opacity: 0;
height: 42px;
color: var(--color);
box-shadow: 0 4px 8px 0 hsl(0 0% 0% / 0.2);
position: fixed;
bottom: 3rem;
left: 50%;
translate: 0% 0;
margin-left: calc(var(--width) * -0.5px);
border-radius: 100px;
background: linear-gradient(var(--bg), var(--bg)) padding-box,
linear-gradient(var(--bd-top), var(--bd-bottom)) border-box;
border: 1px solid #0000;
transition: opacity 0s var(--transition);
}
nav button {
color: canvasText;
position: absolute;
left: 0;
top: 0;
translate: -100% -50%;
opacity: 0.25;
transition: opacity calc(var(--speed) * 1s);
&:is(:hover, :active) {
opacity: 1;
}
}
.nav:has(ul:is(:hover, :focus-within)) button {
opacity: 0;
}
.nav :where(a, button) {
width: 32px;
aspect-ratio: 1;
border-radius: 50%;
display: grid;
place-items: center;
text-decoration: none;
border: 0;
cursor: pointer;
font-weight: 500;
color: inherit;
background: transparent;
&:is(:focus-visible) {
outline-color: transparent;
outline-width: 0px;
background: var(--tip);
}
}
.nav ul {
display: flex;
padding: 0;
margin: 0;
list-style-type: none;
}
li svg {
width: 24px;
}
/* Positioning stuff */
.nav {
anchor-name: --nav;
}
.tip {
position: fixed;
position-anchor: --nav;
background: var(--tip);
color: var(--color);
font-size: 0.875rem;
border-radius: 100px;
width: 100px;
pointer-events: none;
overflow: hidden;
border: 1px solid
light-dark(
color-mix(in hsl, var(--bd-top), canvasText 15%),
color-mix(in hsl, var(--bd-top), canvasText 15%)
);
height: var(--tip-height);
z-index: 999999999;
}
.x {
width: 18px;
}
[data-debug='true'] .tip {
overflow: visible;
.tip__track {
outline: 1px dashed orange;
outline-offset: 1px;
}
.tip__track div {
opacity: 1;
outline: 1px dashed red;
}
}
.tip__track {
display: grid;
height: var(--tip-height);
}
[data-flow='horizontal'] .tip,
[data-flow='auto'][data-o.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0