Skip to content

Commit

Permalink
completed hidden search
Browse files Browse the repository at this point in the history
  • Loading branch information
tsr-kairi committed Jun 29, 2021
1 parent dab0b6c commit 5fb990b
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Day 4 - Hidden Search Widget/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!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" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="./style.css" />
<title>Hidden | Search</title>
</head>
<body>
<div class="search">
<input type="text" class="input" placeholder="Search..." />
<button class="btn">
<i class="fas fa-search"></i>
</button>
</div>

<script src="./script.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions Day 4 - Hidden Search Widget/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Block element and variables
const search = document.querySelector(".search");
const btn = document.querySelector(".btn");
const input = document.querySelector(".input");

// Add Event Listener
btn.addEventListener("click", () => {
search.classList.toggle("active");
input.focus();
});
60 changes: 60 additions & 0 deletions Day 4 - Hidden Search Widget/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@import url("https://fonts.googleapis.com/css2?family=Lato&family=Pattaya&display=swap");

*::after,
*::before {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
background-image: linear-gradient(90deg, #7d5fff, #7158e2);
font-family: "Lato", sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}

.search {
position: relative;
height: 30px;
}

.search .input {
background-color: #fff;
border: 0;
font-size: 17px;
padding: 10px;
height: 30px;
width: 30px;
transition: width 0.3s ease;
}

.btn {
background-color: #fff;
border: 0;
cursor: pointer;
font-size: 22px;
position: absolute;
top: 0;
left: 0;
height: 50px;
width: 50px;
transition: transform 0.3s ease;
}

.btn:focus,
.input:focus {
outline: none;
}

.search.active .input{
width: 200px;
}

.search.active .btn{
transform: translateX(198px);
}

0 comments on commit 5fb990b

Please sign in to comment.