js+svg实现输入框自定义长颈鹿光标效果代码

代码语言:html

所属分类:表单美化

代码描述:js+svg实现输入框自定义长颈鹿光标效果代码

代码标签: 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".........完整代码请登录后点击上方下载按钮下载查看

网友评论0