i am having trouble with making the input cursor to blink. How do you make an animation that the cursor "|" inside the input field (placeholder) keeps blinking. The code that i have is this:
<input type="text" class="rq-form-element" placeholder="|"/>
I have no idea on how to get this even started. Any suggestions?
Alternatively referred to as a caret, a cursor or text cursor is a blinking horizontal or vertical line ( ) that indicates where new text starts when you begin to type.
In applications such as Microsoft Word, the cursor changes to a vertical bar that blinks to indicate where you are in the document. But a cursor that flashes rapidly or flickers erratically may indicate problems with the mouse or mouse drivers, video problems or a cursor blink rate that is set too high.
Just add autofocus
attribute. See the link here
<input type="text" class="rq-form-element" autofocus/>
The autofocus
attribute is a boolean
attribute.
When present, it specifies that an element should automatically get focus
when the page loads
.
Try this solution
<div class="cursor">
<input type="text" class="rq-form-element" />
<i></i>
</div>
CSS
.cursor {
position: relative;
}
.cursor i {
position: absolute;
width: 1px;
height: 80%;
background-color: gray;
left: 5px;
top: 10%;
animation-name: blink;
animation-duration: 800ms;
animation-iteration-count: infinite;
opacity: 1;
}
.cursor input:focus + i {
display: none;
}
@keyframes blink {
from { opacity: 1; }
to { opacity: 0; }
}
Live demo - https://jsfiddle.net/dygxxb7n/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With