File tree 3 files changed +86
-0
lines changed
3 files changed +86
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 " />
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6
+ < link
7
+ rel ="stylesheet "
8
+ href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css "
9
+ integrity ="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA== "
10
+ crossorigin ="anonymous "
11
+ />
12
+ < link rel ="stylesheet " href ="style.css " />
13
+ </ head >
14
+ < body >
15
+ < div class ="search ">
16
+ < input type ="text " class ="input " placeholder ="Search... " />
17
+ < button class ="btn "> < i class ="fas fa-search "> </ i > </ button >
18
+ </ div >
19
+ < script src ="script.js "> </ script >
20
+ </ body >
21
+ </ html >
Original file line number Diff line number Diff line change
1
+ const search = document . querySelector ( ".search" ) ;
2
+ const btn = document . querySelector ( ".btn" ) ;
3
+ const input = document . querySelector ( ".input" ) ;
4
+
5
+ btn . addEventListener ( "click" , ( ) => {
6
+ search . classList . toggle ( "active" ) ;
7
+ input . focus ( ) ;
8
+ } ) ;
Original file line number Diff line number Diff line change
1
+ @import url ("https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" );
2
+
3
+ * {
4
+ box-sizing : border-box;
5
+ }
6
+
7
+ body {
8
+ background-image : linear-gradient (90deg , # 7d5fff, # 7158e2 );
9
+ font-family : "Roboto" , sans-serif;
10
+ display : flex;
11
+ align-items : center;
12
+ justify-content : center;
13
+ height : 100vh ;
14
+ overflow : hidden;
15
+ margin : 0 ;
16
+ }
17
+
18
+ .search {
19
+ position : relative;
20
+ height : 50px ;
21
+ }
22
+
23
+ .search .input {
24
+ background-color : # fff ;
25
+ border : 0 ;
26
+ font-size : 18px ;
27
+ padding : 15px ;
28
+ height : 50px ;
29
+ width : 50px ;
30
+ transition : width 0.3s ease;
31
+ }
32
+
33
+ .btn {
34
+ background-color : # fff ;
35
+ border : 0 ;
36
+ cursor : pointer;
37
+ font-size : 24px ;
38
+ position : absolute;
39
+ top : 0 ;
40
+ left : 0 ;
41
+ height : 50px ;
42
+ width : 50px ;
43
+ transition : transform 0.3s ease;
44
+ }
45
+
46
+ .btn : focus ,
47
+ .input : focus {
48
+ outline : none;
49
+ }
50
+
51
+ .search .active .input {
52
+ width : 200px ;
53
+ }
54
+
55
+ .search .active .btn {
56
+ transform : translateX (198px );
57
+ }
You can’t perform that action at this time.
0 commit comments