Creating captivating animations using CSS and HTML input

I am currently in the process of building a website and I am interested in adding an animated search feature to it. I came across this animation that has caught my attention:

https://videohive.net/item/search-logo-reveal/19279469?s_rank=149
. I was wondering if there is a way for me to incorporate something similar into my own site. Here is the code I have been working on: https://jsfiddle.net/4txmdqhx/. Please note that there may be some optimization errors as I am still new to this.

Thank you!

Answer №1

$('.custom-input input,.custom-input textarea').focus(function() {
    $(this).parent().addClass('active');
});

$('.custom-input input,.custom-input textarea').blur(function() {
    $(this).parent().removeClass('active');
});
<style>
.active {
  color:blue;   
}
.custom-input {
position: relative;
margin: 30px 0;
}
.custom-input label {
position: absolute;
top: 5px;
left: 10px;
padding:5px;
}

.custom-input.active label {
top: -25px;
left: 10px;
/*background: #ffffff;*/
}
.custom-input input[type="text"] {
padding-left: 80px;
}
.custom-input textarea {
padding-left: 80px;
}
.custom-input.active textarea, 
.custom-input.active input[type="text"] {
padding-left: 10px;
}
textarea,
input[type="text"] {
padding: 10px;
width: 100%;
}
textarea,
input,
.custom-input.active label,
.custom-input label {
-webkit-transition: all 0.2s ease-in-out;
       -moz-transition: all 0.2s ease-in-out;
         -o-transition: all 0.2s ease-in-out;
            transition: all 0.2s ease-in-out;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="row">
    <form>
        <div class="custom-input">
            <label>Name :</label>
            <input type="text">
        </div>
        <div class="custom-input">
            <label>Email :</label>
            <input type="text">
        </div>
        <div class="custom-input">
            <label>Number :</label>
            <input type="text">
        </div>
        <div class="custom-input">
            <label>Name :</label>
            <input type="text">
        </div>
        <div class="custom-input">
            <label>Name :</label>
            <input type="text">
        </div>
        <div class="custom-input">
            <label>Message :</label>
            <textarea cols="10" rows="5"></textarea>
        </div>
    </form>
    </div>
</div>

Answer №2

Give this method a try

.searchbar{
width: 180px;
height: 26px;
animation-name: searchbar-animation;
animation-duration: 6s;
}   
@keyframes searchbar-animation{
0%{width: 0px;}
25%{width: 45px;}
50%{width: 90px;}
75%{width: 135px;}
100%{width: 180px;}
 }

You have the flexibility to adjust the width, height, and animation duration as per your requirements.

<form>     
<input   class="searchbar" 
type="text" value="type your text here">
</form>
</div>

Answer №3

Give this a shot, with an added border that you can customize to your preference

.searchbar{
width: 200px;
height: 24px;
animation-name: searchbar;
animation-duration: 5s;
border: 2px solid;
}   
@keyframes searchbar{
0%{width: 0px;
border-top-color: green;}
20%{width: 40px;
 border-right-color: red;}
40%{width: 80px; 
border-bottom-color: gold;}
60%{width: 120px; 
border-left-color: blue;}
80%{width: 160px; 
 border-top-color: pink;}
100%{width: 200px;}
 }

Also,

<input   class="searchbar" 
type="text" value="enter text here">
</form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

trigger a border hover effect on an HTML element

Is it possible to attach a mouseover event specifically to the left border of a div element in HTML? The div serves as a container for various other intricate HTML elements, each with their own mouseover events. While binding a mouseover event to the enti ...

The accuracy of VW and VH units is questionable

width: 100vw;/* Taking up the entire viewport width */ height: 100vh;/* Occupying the full height of the viewport*/ Despite my efforts to make this CSS match the exact dimensions of the viewport at 100%, it seems to be too large and causing overflow on th ...

Using JSTL tags may result in returning null or empty values when making Javascript calls or populating HTML

This strange error is puzzling because it appears on some of the webpages I create, but not on others, even though the elements are exactly the same. For instance, this issue does not occur: <main:uiInputBox onDarkBG="${hasDarkBG}" name="quest ...

Dealing with complications in the Rails asset pipeline management

I am working on a webpage that requires real-time data to be displayed. Therefore, it necessitates continuous ajax communication post page load. similar to this, jQuery -> setInterval -> $.ajax url: "some url" success: (data, te ...

Any ideas on how I can use PHP or JavaScript to repeatedly execute a segment of HTML code?

I recently tried using a for loop and heredoc in PHP with code that looks something like this: $options = ''; for($Year = date("Y"); $Year <= date("Y") + 5; $Year++) { $options .= "<option>$Year</option>\n"; } $Select = ...

Utilizing Multiple Columns for Labels in Twitter Bootstrap

In my form, I have the following code: <div class="row"> <div class="col-md-12"> <div class="form-group"> <label class="control-label"> States ...

Text appearing in varying sizes across browsers

I need some help with a coding issue I'm facing. I have a form where one of the inputs is connected to a JavaScript function that updates a div on the page as the user types. However, I want to limit the width of this div to 900px and make sure it onl ...

The continuation of unraveling the mystery of utilizing `overflow-y:scroll` in a horizontal slider

As a beginner, I realized too late that adding code in comments is not an option. Consequently, I decided to create a new question and ask for your assistance once again. To optimize the use of space, I have implemented bxSlider with fixed dimensions (wid ...

Preventing scrolling on a YouTube video embed

I have been working hard on developing my personal website. One issue I encountered is that when there is a YouTube video embedded in the site, it stops scrolling when I hover over it. I would like the main document to continue scrolling even if the mouse ...

Ways to improve the quality of a blurred photo

I've recently put together a test landing page using bootstrap: Upon visiting the site and viewing the iPhone screenshot, it's clear that the text on the screen is quite blurry. Interestingly, by simply resizing the browser window and then maxi ...

Switch a div to a computed location

I'm having trouble getting this code to animate a div to a calculated position. Can someone please help me troubleshoot? $(document).ready(function() { var is_Clicked = false; $("#togglebutton").click(function() { if (is_Cli ...

Encountering difficulty selecting a dropdown sub-menu using Selenium WebDriver

I'm currently working on automating a website with selenium webdriver. The issue I'm encountering is that when I try to click on a menu item, the submenu pops up (actually a misplaced dropdown, UI issue), and although I can locate the element of ...

jQuery's simple scrolling feature is currently not functioning as intended

Could someone explain why the following code snippet is not functioning correctly? The objective is to smoothly scroll the screen to an anchor destination, taking into account the height of a fixed header with ID "jeden". $(document).ready(function() { ...

Experiencing odd behavior with my Dash App when using CSS grid on it

Seeking assistance with my coding issue, I believe sharing my code from Github would be the most efficient way to address it. An exclusive branch named css_problem_branch has been created to showcase the problem at hand. To access the Github repository, p ...

What could be causing the compatibility issue between fr units and grid-template-rows in CSS grid?

I'm having trouble getting the row height to change using fr units in my grid-template-rows. It seems to work fine with other units like pixels, but not with fr. I find it confusing that the fr units work perfectly fine with grid-template-columns, so ...

Choosing JavaScript

<select> <script type="text/javascript"> $.get( 'http://www.ufilme.ro/api/load/maron_online/470', function(data){ var mydata = new Array(); var i = 0; // индекс масси ...

After the URL of the window was updated, the local storage was automatically cleared

function makeAjaxCall(){ ............... ............... success:function(response){ localStorage.setItem("token", response['token']) window.location.href="https://www.example.com/profiler/" } } The code snippet above is fo ...

Prevent multiple sliding menu animations - .stop()

I'm encountering a problem with my sliding menu (3 levels). When I quickly move the mouse over the menu, it ends up sliding up and down multiple times. I've heard that using the jQuery function .stop() can fix this issue, but I'm not sure h ...

Performing two API calls using Jquery to fetch distinct dynamic elements within two nested $.each loops

There's an API link that contains crucial data about phone brands. From this initial data, I have to create a second API call for each brand to gather more detailed information. For example, the first JSON file (urlphonebrands) lists 3 phone brands - ...

Sticky sidebar that adjusts to viewport size in a responsive layout

When designing a CSS fluid layout, most divs utilize percentages to adjust based on the viewport size. However, I have a specific scenario where I need my sidebar to maintain a fixed position. For instance: <aside style="width:25%; float:left; positio ...