Today I will be teaching you how to create a search bar for your website using only HTML and CSS
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="content">
<input type="text" name="search" id="search" placeholder="Search">
<button type="button" id="searchButton"></button>
</div>
</body>
</html>
CSS
*{
padding: 0;
margin: 0;
}
body{
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(to right, #cb2d3e, #ef473a);
}
div{
display: flex;
justify-content: center;
align-items: center;
height: 4vw;
width: 45 vw;
background-color: black;
border-radius: 45px;
background-color: rgba(0, 0, 0, 0.7);
}
#search{
height: 3vw;
font-size: 2vh;
border: none;
width: 42vw;
background-color: rgba(0, 0, 0, 0);
outline: none;
color: white;
padding-left: 2vh;
}
#searchButton{
height: 3vw;
width: 3vw;
margin-right: 0.7vw;
background-image: url(images/icons8-search.svg), linear-gradient(to right, #cb2d3e, #ef473a);
background-size: cover;
background-repeat: no-repeat;
outline: none;
cursor: pointer;
border: none;
border-radius: 90px;
}
#searchButton:hover{
opacity: 0.7;
}
If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on
YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ
Instagram: https://www.instagram.com/coding_for_the_web/
Twitter: https://twitter.com/LearnWebCoding
Comments