js+css实现土拨鼠分页动画效果代码
代码语言:html
所属分类:布局界面
代码描述:js+css实现土拨鼠分页动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css?family=Rubik+Mono+One&display=swap" rel="stylesheet"> <style> :root { --body-background-color: #2c303a; /* content */ --size: 48px; --white: #fff; --marmot-body-color: #ba7935; --marmot-face-color: darkslategray; } .container { position: relative; display: flex; place-content: center; column-gap: calc(var(--size) / 2); color: var(--white); .dot { position: relative; inline-size: var(--size); block-size: var(--size); display: grid; place-content: center; cursor: pointer; &:hover { .grass { translate: 0 -4px; } .marmot { opacity: 1; translate: -50% 12px; .eyes { animation: eyes 2s; } } } &.active { color: var(--marmot-body-color); .grass { translate: 0 -32px; } .marmot { opacity: 1; translate: -50% -12px; } } } } .grass, .marmot { transition: 250ms; } .grass { z-index: -1; translate: 0 12px; inline-size: calc(var(--size) / 1.25); block-size: var(--size); margin-inline: auto; clip-path: polygon( 11% 100%, 88% 100%, 80% 83%, 81% 53%, 70% 69%, 65% 84%, 58% 63%, 66% 28%, 43% 55%, 39% 85%, 28% 46%, 6% 26%, 13% 46%, 17% 64%, 19% 80%, 4% 69% ); background-color: green; } .pot { position: relative; inline-size: var(--size); block-size: var(--size); display: grid; place-content: center; clip-path: polygon(0 0, 100% 0, 100% 35%, 90% 100%, 10% 100%, 0 35%); background-image: linear-gradient(0.935turn, #b9491d, #833636); &::before { content: ''; position: absolute; top: 30%; left: 10%; inline-size: 80%; height: 1px; background-color: #833636; } } .marmot { position: absolute; left: 50%; translate: -50% 16px; z-index: -1; inline-size: calc(var(--size) - 8px); block-size: calc(var(--size) / 1.25); border-top-left-radius: calc(var(--size) / 1); border-top-right-radius: calc(var(--size) / 1); background-color: var(--marmot-body-color); opacity: 0; .ears { inline-size: 100%; display: flex; justify-content: space-between; .ear { inline-size: 12px; block-size: 12px; margin-block-start: -4px; background-image: radial-gradient( sandybrown 20%, var(--marmot-body-color) 40% ); border-radius: 50%; } } .eyes { inline-size: 60%; margin-inline: auto; display: flex; justify-content: space-between; .eye { position: relative; inline-size: 6px; block-size: 6px; border-radius: 2px; background-color: var(--marmot-face-color); &::before { content: ''; position: absolute; top: 1px; left: 1px; inline-size: 2px; block-size: 2px; border-radius: inherit; background-color: var(--white); } } } .nose { inline-size: 10px; block-size: 6px; margin-inline: auto; margin-block-start: 2px; border-radius: 2px 2px 4px 4px; background-color: var(--marmot-face-color); } .mouth { inline-size: 16px; block-size: 4px; margin-inline: auto; margin-block-start: -4px; border-bottom: 2px solid var(--marmot-face-color); border-radius: 8px; } .tooths { margin-inline: auto; display: flex; justify-content: center; .tooth { inline-size: 4px; block-size: 4px; background-color: var(--white); } } } body { box-sizing: border-box; margin: 0; height: 100dvh; display: grid; place-content: center; font-family: "Rubik Mono One", sans-serif; font-weight: 500; background-color: var(--body-background-color); background-image: repeating-linear-gradient(0turn, currentColor, transparent 1px, transparent); background-size: 48px 48px; } @keyframes eyes { 25% { translate: -2px; } 50% { translate: 0; } 75% { translate: 2px; } } </style> </head> <body > <div class="container"> <div class="dot"> <div class="grass"></div> <div class="pot">1</div> <div class="marmot"> <div class="ears"> <div class="ear right"></div> <div class="ear left"></div> </div> <div class="eyes"> <div class="eye right"></div> <div class="eye left"></div> </div> <div class="nose"></div> <div class="mouth"></div> <div class="tooths"> <div class="tooth"></div> </div> </div> </div> <div class="dot"> <div class="grass"></div> <div class="pot">2</div> <div class="marmot"> <div class="ears"> <div class="ear right"></div> <div class="ear left"></div> </div> <div class="eyes"> <div class="eye right"></div> <div class="eye left"></div> </div> .........完整代码请登录后点击上方下载按钮下载查看
网友评论0