js+svg实现万圣节幽灵般南瓜头文字输入框效果代码
代码语言:html
所属分类:表单美化
代码描述:js+svg实现万圣节幽灵般南瓜头文字输入框效果代码,在输入框中输入文字,就会弹出南瓜头,继续输入,发现文字在南瓜头的嘴里显示出来。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> /* background pattern from heropatterns.com */ @import url("https://fonts.googleapis.com/css2?family=Titan+One&display=swap"); @font-face { font-family: "Stranger"; src: url("//repo.bfw.wiki/bfwrepo/font/StrangerbackintheNight.woff2") format("woff2"); } body, html { height: 100%; display: grid; } body { height: 100vh; width: 100vw; overflow: hidden; } body:before { content: ""; position: absolute; width: 100%; height: 100%; left: 0; top: 0; backdrop-filter: invert(1) saturate(0); z-index: 1; } .gourd { position: absolute; width: 500px; height: 200px; background: rgba(0, 0, 0, 0.5); border-radius: 5px; box-shadow: inset 0 0 0 rgba(0, 0, 0, 0), inset 0 0 0 rgba(0, 0, 0, 0), 0 0 0 1px #eca43a, 0 20px 40px -20px rgba(0, 0, 0, 0.25); left: calc(50% - 250px); top: 50%; transform: translateY(calc(-50% - 25px)); transform-origin: bottom; transition: all 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275); transition-delay: 0.25s; will-change: transform, box-shadow, height, border-radius; transform-style: preserve-3d; border-radius: 10px; z-index: 2; } .gourd:after { content: ""; position: absolute; width: 100px; height: 50px; background: linear-gradient(-25deg, #7baa50, #7baa50 45%, #6f9948 50%, #88b460 55%); border-radius: 100px 0 100px 0; left: 265px; top: -75px; transition: 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-origin: 0% 100%; transform: scale(0, 0.5); } .gourd:before { content: ""; position: absolute; width: 60px; height: 120px; background: radial-gradient(ellipse at center, #628840 30px, #88b460 30px) 50% 0%/60px 30px no-repeat, #88b460; box-shadow: inset -5px 0 20px #628840, inset 5px 0 20px #628840, 0 5px 40px rgba(0, 0, 0, 0.25); border-radius: 100px/50px; top: -100px; left: calc(50% - 30px); transition: 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275); height: 120px; transform: scaleY(0); transform-origin: bottom; } .gourd .eye { position: absolute; left: 100px; top: 80px; height: 50px; width: 80px; border-radius: 150px 150px 0 0/200px 200px 0 0; background: #241703; box-shadow: inset 0 5px 0 5px #98600f; transition: 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-origin: bottom; transform: scaleY(0); } .gourd .eye:before { content: ""; position: absolute; width: 30px; height: 17.5px; background: #eca43a; bottom: 0; left: calc((50% - 50px) + (var(--char-total) * 7.5px)); box-shadow: calc(10px - (var(--char-total) * 2px)) -1px 0 1px #af6f11; border-radius: 50px 50px 0 0; transition: transform 400ms cubic-bezier(0.175, 0.885, 0.32, 1.275), left 0.25s ease-in-out, box-shadow 0.25s ease-in-out; transform-origin: bottom; transform: scaleY(0); } .gourd .eye:last-of-type { left: auto; right: 100px; } svg { position: absolute; z-index: 9; width: 400px; height: 400px; left: calc(50% - 200px); top: calc(50% - 187.5px); } svg path { transition: 0.2s ease-in-out; } svg path.mouth1, svg path.mouth2 { stroke: #eca43a; stroke-width: 0px; } svg path.mouth2 { stroke: #0c0801; stroke-width: 4px; } svg foreignObject .pumpkin h1 span.word span.char { transform: translateY(150%); transition: 0.2s ease-in-out.........完整代码请登录后点击上方下载按钮下载查看
网友评论0