div+css实现南瓜头显示脸部开关效果代码
代码语言:html
所属分类:布局界面
代码描述:div+css实现南瓜头显示脸部开关效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> *, ::before, ::after { box-sizing: border-box; } body { background-image: radial-gradient(rgb(111, 111, 184), black 60%); color: #f1f5f9; min-height: 100svh; display: grid; place-content: center; overflow: hidden; font-family: system-ui, sans-serif; } /* @media (prefers-reduced-motion: no-preference) { body::before { content: ""; position: fixed; inset: 0; margin: auto; background-image: url("https://raw.githubusercontent.com/cbolson/icodethis-challenges/main/assets/images/smoke-ani.webp"); opacity: 0.4; background-size: cover; background-position: center; background-repeat: no-repeat; z-index: -1; } } */ .pumpkin-wrapper { --pumpkin-clr: rgb(249, 115, 22); --pumpkin-stem-clr: rgb(77, 124, 15); --pumpkin-eye-clr: black; position: relative; width: 300px; height: 200px; display: grid; grid-template-areas: "stack"; place-items: center; } /* WIP .pumpkin-wrapper:hover > :where(:not(:is(label,.hashtag))){ transform: scale(1.1); } */ .pumpkin-wrapper::before { content: ""; position: absolute; bottom: 2rem; width: 200%; height: 4px; background-color: black; } .pumpkin-wrapper::after { content: ""; position: absolute; bottom: -0.5rem; z-index: -3; width: 70%; height: 30px; background-color: #000; border-radius: 50%; filter: blur(10px); opacity: 0.5; } .pumpkin-wrapper > div { grid-area: stack; width: 120px; height: 100%; color: var(--pumpkin-clr); background-color: var(--pumpkin-clr); border-radius: 50% 50% 45% 45%; border: 10px solid black; /*transition: transform 500ms cubic-bezier(0.47, 1.64, 0.41, 0.8);*/ box-shadow: inset 3px 5px 3px rgba(255 255 255 / 0.5), inset -5px -3px 20px rgba(0 0 0 / 0.65); } .pumpkin-wrapper > div:nth-child(1) { translate: -60px -10px; rotate: 12deg; scale: 1.3 0.9; border-left-width: 3px; } .pumpkin-wrapper > div:nth-child(3) { translate: -40px -5px; rotate: 6deg; scale: 1.1 0.95; border-right: none; border-left: none; } .pumpkin-wrapper > div:nth-child(4) { translate: 40px -5px; rotate: -6deg; scale: 1.1 0.95; border-right: none; border-left: none; } .pumpkin-wrapper > div:nth-child(2) { translate: 60px -10px; rotate: -12deg; scale: 1.3 0.9; border-right-width: 3px; } .pumpkin-wrapper > div:nth-child(5) { translate: 0; border-right: none; border-left: none; } .pumpkin-wrapper > p { position: absolute; transition: scale 300ms cubic-bezier(0.47, 1.64, 0.41, 0.8), opacity 300ms cubic-bezier(0.47, 1.64, 0.41, 0.8); } .pumpkin-wrapper > [data-face] { scale: var(--face-scale, 0); opacity: var(--face-opacity, 0); } .pumpkin-wrapper > .stem { left: 50%; bottom: 100%; translate: -30% 50%; z-index: -1; width: 20px; height: 60px; /*transition: transform 1000ms ease-in-out;*/ background-color: var(--pumpkin-stem-clr); border: 5px solid black; border-bottom: 10px solid black; border-right-width: 3px; border-left-width: 3px; border-radius: 20px 25px 20px 5px / 50px 46px 40px 30px; rotate: 15deg; box-shadow: inset 3px 5px 3px rgba(255 255 255 / 0.5), inset -5px -7px 3px rgba(0 0 0 / 0.5); } .pumpkin-wrapper > .eye { top: 15%; background: var(--pumpkin-eye-clr); .........完整代码请登录后点击上方下载按钮下载查看
网友评论0