Skip to content

Commit 9020f6e

Browse files
authored
Merge pull request #903 from OAAK125/input-field
adding input-text field
2 parents b3ba2ef + 6969893 commit 9020f6e

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

Input Field/index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Floating Label Input</title>
8+
<link rel="stylesheet" href="style.css" />
9+
</head>
10+
11+
<body>
12+
13+
<div class="input-container">
14+
<input type="text" id="input" required />
15+
<label for="input" class="label">Enter Text</label>
16+
<div class="underline"></div>
17+
</div>
18+
19+
</body>
20+
21+
</html>

Input Field/style.css

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
* {
2+
box-sizing: border-box;
3+
}
4+
5+
body {
6+
height: 100vh;
7+
margin: 0;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
background-color: #f4f7fb;
12+
font-family: "Poppins", sans-serif;
13+
}
14+
15+
.input-container {
16+
position: relative;
17+
width: 250px;
18+
}
19+
20+
.input-container input[type="text"] {
21+
font-size: 1rem;
22+
width: 100%;
23+
border: none;
24+
border-bottom: 2px solid #b0bec5;
25+
padding: 8px 0;
26+
background-color: transparent;
27+
outline: none;
28+
color: #222;
29+
}
30+
31+
.input-container .label {
32+
position: absolute;
33+
top: 0;
34+
left: 0;
35+
color: #78909c;
36+
transition: all 0.3s ease;
37+
pointer-events: none;
38+
}
39+
40+
.input-container input[type="text"]:focus ~ .label,
41+
.input-container input[type="text"]:valid ~ .label {
42+
top: -20px;
43+
font-size: 0.85rem;
44+
color: #1565c0; /* highlight color */
45+
}
46+
47+
.input-container .underline {
48+
position: absolute;
49+
bottom: 0;
50+
left: 0;
51+
height: 2px;
52+
width: 100%;
53+
background-color: #1565c0;
54+
transform: scaleX(0);
55+
transition: transform 0.3s ease;
56+
transform-origin: left;
57+
}
58+
59+
.input-container input[type="text"]:focus ~ .underline,
60+
.input-container input[type="text"]:valid ~ .underline {
61+
transform: scaleX(1);
62+
}

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Please be aware that the demos may exhibit significant accessibility issues, suc
7070
- [Image Comparison Slider](#image-comparison-slider)
7171
- [Infinite Carousel](#infinite-carousel)
7272
- [Info on Hover / Popover](#info-on-hover-popover)
73+
- [Input Text Field](#input-text)
7374
- [Interactive Resume](#interactive-resume)
7475
- [Jumping Ball](#jumping-ball)
7576
- [Light Bulb Animation](#light-bulb-animation)
@@ -1317,6 +1318,18 @@ An interactive resume built entirely using **HTML and CSS** — featuring animat
13171318

13181319
[<img src="images/rotating_text.mp4" height="230" title="Demo">]()
13191320

1321+
## <a id="input-text"></a>Input Text Field
1322+
1323+
[<video height="230" width="230" controls>
1324+
<source src="images/input-text.mp4" type="video/mp4">
1325+
</video>
1326+
]()
1327+
1328+
**[⬆ back to top](#quick-links)**
1329+
1330+
---
1331+
1332+
13201333
**[⬆ back to top](#quick-links)**
13211334

13221335
## Contributors

images/input-text.mp4

873 KB
Binary file not shown.

0 commit comments

Comments
 (0)