div+css实现可爱互动按钮悬浮点击跳出卡通人效果代码
代码语言:html
所属分类:其他
代码描述:div+css实现可爱互动按钮悬浮点击跳出卡通人效果代码
代码标签: div css 可爱 互动 按钮 悬浮 点击 跳出 卡通人
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> @import url("https://fonts.googleapis.com/css2?family=Acme&display=swap"); :root { font-family: "Acme", sans-serif; } body { background-image: radial-gradient(#e88420, #740b85); width: 100vw; height: 100vh; display: flex; } div { box-sizing: border-box; } #TrickOrTreat { margin: auto; position: relative; } .container { width: 100%; height: 100%; position: absolute; top: 0; left: 0; } .head { width: 4.2rem; height: 4rem; position: relative; } .face { background-color: #f7d199; width: 100%; height: 100%; overflow: hidden; position: relative; transform-style: preserve-3d; perspective: 1000px; border-radius: 99999px; } .face * { transform-style: preserve-3d; } .face-container { width: 100%; height: 100%; transform-origin: center center 2rem; transform: translateZ(2rem); } .eye { background-color: #000000; width: 0.4rem; height: 0.4rem; position: absolute; top: 2.2rem; border-radius: 99999px; } .eye.left { left: 1rem; } .eye.right { right: 1rem; } .eye::after { content: ""; background-color: #ffffff; width: 0.09rem; height: 0.09rem; position: absolute; top: 0.09rem; left: 0.09rem; border-radius: 99999px; } .blush { background-color: #f79999; width: 1.2rem; height: 1.2rem; position: absolute; top: 2.7rem; border-radius: 99999px; filter: blur(4px); } .blush.left { left: 0.3rem; } .blush.right { right: 0.3rem; } .mouth { width: 0.9rem; height: 0.4rem; border: solid 0.125rem #000000; border-top: 0; position: absolute; top: 2.95rem; left: calc(50% - 0.45rem); border-radius: 0 0 99999px 99999px; } .hair { background-color: #000000; width: 4.6rem; height: 2.7rem; position: absolute; top: -0.9rem; left: calc(50% - 2.3rem); border-radius: 99999px 99999px 0 0; } .hair-1 { background-color: #000000; width: 2.5rem; height: 2.5rem; position: absolute; top: 1.2rem; } .hair-1.left { left: -1.75rem; border-radius: 50% 50% 50% 0; transform: skew(-15deg) rotate(-25deg); } .hair-1.right { right: -1.75rem; border-radius: 50% 50% 0 50%; transform: skew(15deg) rotate(25deg); } .hat { position: absolute; top: 0; left: 50%; } .hat .hat-top { background-image: linear-gradient(45deg, transparent 0% 50%, #8d65c9 50% 100%); width: 3.8rem; height: 3.8rem; overflow: hidden; position: absolute; top: -1.75rem; left: calc(50% - 1.9rem); transform: rotate(-55deg) skew(-20deg); } .hat .hat-top .hat-ribbon { background-color: #d14949; width: 5rem; height: 0.75rem; position: absolute; top: calc(calc(50% - 0.375rem) - 0.5rem); left: calc(calc(50% - 2.5rem) + 0.5rem); border-radius: 50% 50% 0% 0%/100% 100% 0% 0%; transform: rotate(43.75deg); } .hat .hat-bottom { background-color: #8d65c9; width: 6.75rem; height: 1.75rem; position: absolute; top: -0.5rem; left: calc(50% - 3.375rem); border-radius: 50% 50% 25% 25%/75% 75% 25% 25%; } .hat .hat-bottom::after { content: ""; background-color: #000000; width: 4.8rem; height: 1.15rem; position: absolute; bottom: 0; left: calc(50% - 2.4rem); border-radius: 50% 50% 0% 0%/100% 100% 0% 0%; } .body-1 { width: 0px; height: 0px; position: absolute; top: 0; left: 50%; transform-origin: bottom center; } .witch-skirt { width: 0; height: 5rem; border-left: solid 2.25rem transparent; border-right: solid 2.25rem transparent; border-top: 0; border-bottom: solid 5rem #8d65c9; position: absolute; top: 1.7rem; left: calc(50% - 2.25rem); } .witch-skirt::after { content: ""; background-color: #8d65c9; width: 4.5rem; height: 0.5rem; position: absolute; top: 5rem; left: -2.25rem; border-radius: 0 0 50% 50%/0 0 100% 100%; } .witch-shirt { width: 0; height: 3rem; border-left: solid 1rem transparent; border-right: solid 1rem transparent; border-top: 0; border-bottom: solid 3rem #ffffff; position: absolute; top: 1.95rem; left: calc(50% - 1rem); } .witch-shirt::before, .witch-shirt::after { content: ""; background-color: #e3d132; width: 0.5rem; height: 0.5rem; position: absolute; top: 3.25rem; border-radius: 100%; } .witch-shirt::before { right: 0.75rem; } .witch-shirt::after { left: 0.75rem; } .witch-arm { width: 1.5rem; height: 2.5rem; position: absolute; top: 4.4rem; transform-origin: top center; } .witch-arm.left { left: -1.3rem; transform: rotate(65deg); } .witch-arm.left .sleeve { left: 0; } .witch-arm.left .hand { left: 0.1rem; } .witch-arm.right { right: -1.3rem; transform: rotate(-65deg); } .witch-arm.right .sleeve { right: 0; } .witch-arm.right .hand { right: 0.1rem; } .witch-arm .sleeve { background-color: #ffffff; width: 1.2rem; height: 1.9rem; position: absolute; top: 0; border-radius: 99999px 99999px 0 0; } .witch-arm .hand { background-color: #f7d199; width: 0.9rem; height: 1.1rem; position: absolute; bottom: 0; border-radius: 99999px; } .witch-leg { background-color: #f7d199; width: 1rem; height: 2rem; overflow: hidden; position: absolute; top: 6.75rem; border-radius: 0 0 99999px 99999px; transform-origin: top center; } .witch-leg.left { left: -1.25rem; transform: skewX(4deg); } .witch-leg.right { right: -1.25rem; transform: skewX(-4deg); } .witch-leg .shoe { background-color: #371c5e; width: 100%; height: 0.8rem; position: absolute; bottom: 0; } .witch-leg .shoe::after { content: ""; background-color: #f7d199; width: 100%; height: 0.3rem; position: absolute; top: 0; border-radius: 0% 0% 50% 50%/0% 0% 100% 100%; } .person-1 { position: absolute; top: 1.5rem; left: calc(50% - 2.1rem); opacity: 0; transform: scale(0); filter: drop-shadow(0rem 0.5rem 0.75rem rgba(0, 0, 0, 0.5)); transition: top 380ms cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 380ms cubic-bezier(0.18, 0.89, 0.32, 1.28), transform 380ms cubic-bezier(0.18, 0.89, 0.32, 1.28); pointer-events: none; } .peek { width: 0; height: 0; position: absolute; top: 0; left: 50%; visibility: hidden; pointer-events: none; } .peek .hand { background-color: #f7d199; width: 1.125rem; height: 0.6875rem; position: absolute; top: 0rem; border-radius: 99999px 99999px 0 0; filter: drop-shadow(0rem 0.5rem 0.75rem rgba(0, 0, 0, 0.5)); transition: height 380ms ease-out, top 380ms cubic-bezier(0.18, 0.89, 0.32, 1.28), border-radius 380ms ease-out; } .peek .hand.left { left: -3.25rem; } .peek .hand.right { right: -3.25rem; } .pumpkin { background-color: #d96d16; width: 5rem; height: 3rem; border-radius: 99999px; position: absolute; top: 5rem; left: 8rem; opacity: 0; transform: scale(0); filter: drop-shadow(0rem 0.5rem 0.75rem rgba(0, 0, 0, 0.5)); pointer-events: none; } .pumpkin .stem { width: 0; height: 1.25rem; border-left: solid 0.3125rem transparent; border-right: solid 0.3125rem transparent; border-top: solid 1.25rem #356e0d; border-bottom: 0; position: absolute; bottom: 100%; left: calc(50% - 0.3125rem); } .pumpkin .pumpkin-eye { width: 0; height: 0.75rem; border-left: solid 0.575rem transparent; border-right: solid 0.575rem transparent; border-top: 0; border-bottom: solid 0.75rem #1f1f1f; position: absolute; top: 0.5rem; } .pumpkin .pumpkin-eye.left { left: 0.9rem; } .pumpkin .pumpkin-eye.right { right: 0.9rem; } .pumpkin .pumpkin-mouth { background-color: #1f1f1f; width: 3rem; height: 1rem; position: absolute; top: 1.65rem; left: calc(50% - 1.5rem); border-radius: 0 0 99999px 99999px; } .pumpkin .pumpkin-mouth::before, .pumpkin .pumpkin-mouth::after { content: ""; background-color: #d96d16; width: 0.5rem; height: 0.4rem; position: absolute; } .pumpkin .pumpkin-mouth::before { top: 0; left: 0.5rem; } .pumpkin .pumpkin-mouth::after { bottom: 0; left: 1.75rem; } .trick_or_treat:hover:not(:focus) + .container > .person-1, .trick_or_treat:active:not(:focus) + .container > .person-1 { top: -2.75rem; opacity: 1; transform: scale(1); } .trick_or_treat:hover:not(:focus) + .container > .person-1 .face-container, .trick_or_treat:active:not(:focus) + .container > .person-1 .face-container { -webkit-animation: peek 3000ms ease-out infinite; animation: peek 3000ms ease-out infinite; } #TrickOrTreat:not(:target) .trick_or_treat:hover + .container > .peek, #TrickOrTreat:not(:target) .trick_or_treat:active + .container > .peek, #TrickOrTreat:not(:target) .trick_or_treat:active + .container > .peek { visibility: visible; -webkit-animation: to-front 0ms 190ms forwards; animation: to-front 0ms 190ms forwards; } #TrickOrTreat:not(:target) .trick_or_treat:hover + .container > .peek .hand, #TrickOrTreat:not(:target) .trick_or_treat:active + .container > .peek .hand, #TrickOrTreat:not(:target) .trick_or_treat:active + .container > .peek .hand { -webkit-animation: peek-hand-pre 190ms ease-out, to-front 0ms 190ms forwards, peek-hand-post 190ms ease-in forwards; animation: peek-hand-pre 190ms ease-out, to-front 0ms 190ms forwards, peek-hand-post 190ms ease-in forwards; } #TrickOrTreat:target > .container > .person-1 { opacity: 1; transform: scale(1); -webkit-animation: jump 256ms ease-out forwards, to-front 0ms 256ms forwards, fall 256ms ease-in 256ms forwards, go.........完整代码请登录后点击上方下载按钮下载查看
网友评论0