Let’s create an Awesome Search Bar 2 using HTML and CSS. This stylish and modern search bar will feature smooth animations and a clean design to enhance the user interface of any website.
We’ll use:
- HTML to structure the search bar elements.
- CSS to style it with hover effects, smooth transitions, and a minimal layout.
Whether you’re building a personal portfolio, a blog, or a business website, this Awesome Search Bar is a great way to practice front-end skills and add a professional touch to your projects. Let’s get started and make your UI look sleek and functional! 🔍✨
HTML :
This HTML sets up a simple search bar with a Font Awesome search icon; when combined with the linked CSS, it shows a circular button that expands into a search input when hovered, creating a smooth and interactive search UI.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Bar | @coding.stella</title>
<link rel="stylesheet" href="./style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
</head>
<body>
<form action="">
<input type="search" placeholder="Search here ...">
<i class="fa fa-search"></i>
</form>
</body>
</html>
CSS :
This code creates a centered circular search box that expands into a full-width input field with a search icon when hovered; it uses CSS transitions for smooth animation and styling for a modern, clean look with purple accent.
body {
padding: 0;
margin: 0;
height: 100vh;
width: 100%;
background: #252432;
/* background: #8c52ff; */
}
form{
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
transition: all 1s;
width: 50px;
height: 50px;
background: white;
box-sizing: border-box;
border-radius: 25px;
border: 4px solid white;
padding: 5px;
}
input{
position: absolute;
top: 0;
left: 0;
width: 100%;;
height: 42.5px;
line-height: 30px;
outline: 0;
border: 0;
display: none;
font-size: 1em;
border-radius: 20px;
padding: 0 20px;
}
.fa{
box-sizing: border-box;
padding: 10px;
width: 42.5px;
height: 42.5px;
position: absolute;
top: 0;
right: 0;
border-radius: 50%;
color: #8c52ff;
text-align: center;
font-size: 1.2em;
transition: all 1s;
}
form:hover{
width: 300px;
cursor: pointer;
}
form:hover input{
display: block;
}
form:hover .fa{
background: #8c52ff;
color: white;
}
In conclusion, building an Awesome Search Bar 2 using HTML and CSS is a simple yet effective way to upgrade your website’s design. With just a bit of structure and styling, you can create a modern and interactive element that improves user experience. Keep experimenting and making your UI stand out! 💡
If your project has problems, don’t worry. Just click to download the source code and face your coding challenges with excitement. Have fun coding!
