js+svg实现输入框自定义长颈鹿光标效果代码
代码语言:html
所属分类:表单美化
代码描述:js+svg实现输入框自定义长颈鹿光标效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { box-sizing: border-box; } body, input { font-family: "Iowan Old Style", "Palatino Linotype", "URW Palladio L", P052, serif; } body::selection, input::selection { background-color: #feeaa7; color: #8a5836; } body { padding: 40px 20px; background: #ffeaa7; } .giraffe { width: 100%; max-width: 400px; position: relative; margin: 0 auto; } .giraffe-input { background: #fcfef4; outline: none; caret-color: transparent; } .giraffe-input, .giraffe-clone { border: 1px solid #ddd; display: block; padding: 30px 39px; font-size: 30px; width: 100%; } .giraffe-input:focus { border-color: #999; } .giraffe-clone { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; padding-right: 0; display: flex; pointer-events: none; border-color: transparent; color: transparent; } .giraffe-content { white-space: nowrap; } .giraffe-padding { flex: 30px 0 0; height: 100%; min-height: 1em; } .giraffe--caret-visible .giraffe-caret { opacity: 1; } @keyframes blink { 100% { transform: translateX(-100%); } } .giraffe-caret { display: inline-block; transform: translate(-33px, -12px); opacity: 0; transition: opacity 100ms; position: relative; width: 50px; overflow: hidden; } .giraffe-caret svg { animation: blink 1.5s infinite; animation-timing-function: steps(2); width: 100px; height: auto; } </style> </head> <body > <div class="giraffe"> <input placeholder="Start typing..." type="text" class="giraffe-input" /> <div class="giraffe-clone" aria-hidden="true"> <div class="giraffe-content"> <span class="giraffe-before"></span><span class="giraffe-caret"><svg xmlns="http://www.w3.org/2000/svg" width="264" height="211" fill="none" viewBox="0 0 264 211"> <rect width="3.941" height="10.515" x="105.576" y="8" fill="#835A3C" rx="1.97" transform="rotate(14.18 105.576 8)"/> <path fill="#835A3C" d="M92.353 16.341c4.696-3.558 6.184-6.66 3.685-13.02a1.84 1.84 0 0 0-2.758-.841c-5.49 3.76-6.522 7.063-3.74 13.158a1.854 1.854 0 0 0 2.813.703Z"/> <path fill="#F5B953" d="M124.574 19.677 96.681 15.1c-6.793-1.115-13.02 3.99-13.26 10.868-.229 6.539 5.073 11.933 11.616 11.816l28.261-.506a8.86 8.86 0 0 0 1.276-17.602Z"/> <path fill="#F5B953" d="m83.5 27-3 102h-34c-15 0-21.5 9.5-21.5 21v11l1.936 50h7.741L37 161h2l1.935 50h7.742L51 161h19l1.936 50h7.741L82 161h2l1.936 50h7.741L96 161v-32l-2.5-96.5-10-5.5Z" clip-rule="evenodd"/> <path fill="#4D5D7A" d="m26.548 201 .388 10h7.741l.465-10h-8.594ZM40.548 201l.387 10h7.742l.465-10h-8.594ZM71.548 201l.388 10h7.741l.465-10h-8.594ZM85.548 201l.388 10h7.741l.465-10h-8.594Z" clip-rule="evenodd"/> <path fill="#835A3C" d="M86.648 21.154c1.403-5.722.602-9.068-5.346-12.43A1.84 1.84 0 0 0 78.63 9.81c-1.892 6.38-.61 9.594 5.392 12.572a1.854 1.854 0 0 0 2.626-1.227Z"/> <rect width="3.941" height="10.515" x="99.576" y="8" fill="#835A3C" rx="1.97" transform="rotate(14.18 99.576 8)"/> <circle cx="94" cy="25" r="4" fill="#4D5D7A"/> <path stroke="#F5B953" stroke-width="6" d="M8 163.135c0-17 5.5-28.135 27.123-28.135"/> <path fill="#835A3C" d="m13.029 163.331-3.286-2.551a3 3 0 0 0-3.603-.056l-3.624 2.634a3 3 0 0 0-1.034 3.511l3.336 8.604c.979 2.526 4.54 2.563 5.571.057l3.575-8.687a3.001 3.001 0 0 0-.935-3.512Z"/> <path fill="#AF7142" d="M95.256 100.267C91.092 101.275 88 105.026 88 109.5c0 4.644 3.332 8.51 7.737 9.337l-.481-18.57ZM96 153.062a8 8 0 1 0-.37 15.914L96 161v-7.938ZM67.747 161A10.456 10.456 0 0 0 70 154.5c0-5.799-4.701-10.5-10.5-10.5S49 148.701 49 154.5c0 2.454.842 4.712 2.253 6.5h16.494Zm-42.437 7.998.19.002c5.799 0 10.5-4.701 10.5-10.5S31.299 148 25.5 148c-.145 0-.29.003-.433.009-.045.656-.067 1.32-.067 1.991v11l.31 7.998ZM36.01 131c1.686 3.547 5.301 6 9.49 6 4.938 0 9.079-3.408 10.2-8h-9.2c-4.126 0-7.608.719-10.49 2Zm45.........完整代码请登录后点击上方下载按钮下载查看
网友评论0