File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Expand file tree Collapse file tree 3 files changed +92
-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+ < title > Document</ title >
7+ < link rel ="stylesheet " href ="style.css ">
8+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css ">
9+ </ head >
10+ < body >
11+ < div class ="search " id ="search ">
12+ < input type ="text " class ="input " placeholder ="search... ">
13+ < button class ="btn " id ="btn ">
14+ < i class ="fa fa-search "> </ i >
15+ </ button >
16+ </ div >
17+ < script src ="script.js "> </ script >
18+ </ body >
19+ </ html >
Original file line number Diff line number Diff line change 1+ const search = document . getElementById ( 'search' ) ;
2+ const btn = document . getElementById ( 'btn' ) ;
3+ const input = document . querySelector ( 'input' ) ;
4+ btn . addEventListener ( 'click' , ( ) => {
5+ search . classList . toggle ( 'active' ) ;
6+ input . focus ( ) ;
7+ } ) ;
Original file line number Diff line number Diff line change 1+ : root {
2+ --color-filler : # f14949 ;
3+ --color-liner : # f6eeee ;
4+ }
5+
6+ * {
7+ box-sizing : border-box;
8+ }
9+
10+ body {
11+ background-color : var (--color-filler );
12+ font-family : Georgia, 'Times New Roman' , Times, serif;
13+ margin : 0 ;
14+ overflow : hidden;
15+ height : 100vh ;
16+ padding : 20px ;
17+ display : flex;
18+ justify-content : center;
19+ align-items : center;
20+ }
21+
22+ .search {
23+ position : relative;
24+ display : flex;
25+ justify-content : center;
26+ gap : 3% ;
27+ }
28+
29+ .input {
30+ background-color : var (--color-liner );
31+ height : 45px ;
32+ width : 2.5rem ;
33+ border : 5px solid springgreen;
34+ border-radius : 10px ;
35+ padding : 5px ;
36+ transition : width 0.3s ease;
37+ }
38+
39+ .btn {
40+ height : 45px ;
41+ width : 2.5rem ;
42+ border : 5px solid springgreen;
43+ border-radius : 30% ;
44+ font-size : 22px ;
45+ position : absolute;
46+ top : 0 ;
47+ left : 0 ;
48+ transition : transform 0.3s ease;
49+ }
50+
51+ .fa-search {
52+ color : var (--color-filler );
53+ }
54+
55+ .btn : focus ,
56+ .input : focus {
57+ outline : none;
58+ }
59+
60+ .search .active .input {
61+ width : 22rem ;
62+ }
63+
64+ .search .active .btn {
65+ transform : translateX (23rem );
66+ }
You can’t perform that action at this time.
0 commit comments