<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Fancy Material-style Input boxes</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="./style.css">
</head>
<body>
<!-- partial:index.partial.html -->
<section class="wrapper">
<span class="section-header">Label on top</span>
<div class="form-group">
<label class="legend-top">
<input type="text" placeholder="Full Name" />
<span>Full Name</span>
</label>
</div>
<div class="form-group">
<label class="legend-top">
<input type="text" placeholder="Full Name" />
<span>Full Name</span>
</label>
</div>
<span class="section-header">Also works for Select</span>
<div class="form-group">
<label class="legend-top">
<select>
<option>Please select</option>
</select>
<span>Please select an option yo</span>
</label>
</div>
<span class="section-header">Label on the Left</span>
<div class="form-group">
<label class="legend-side">
<input type="text" placeholder="Please enter number" />
<span>Annual Income</span>
</label>
</div>
<div class="form-group">
<label class="legend-side">
<select>
<option>Please Select</option>
</select>
<span>Income type</span>
</label>
</div>
</section>
<!-- partial -->
</body>
</html>
body,
input,
select,
button,
textarea {
font-family: "Lato", sans-serif;
font-size: 16px;
}
.wrapper {
padding: 16px;
width: 480px;
margin: 0 auto;
}
.section-header {
display: block;
text-transform: uppercase;
font-weight: bold;
color: #9FAAB7;
font-size: 11.4285714286px;
margin-bottom: 16px;
}
.form-group {
border: 1px solid #C0CCDA;
margin-bottom: 16px;
border-radius: 4px;
}
.form-group:focus-within {
border-color: #270D7C;
}
.form-group input,
.form-group select {
-moz-appearance: none;
appearance: none;
-webkit-appearance: none;
border: none;
background-color: transparent;
outline: none;
padding: 16px;
display: block;
box-sizing: border-box;
}
.form-group span {
padding: 16px;
color: #9FAAB7;
}
.form-group .legend-top span {
position: absolute;
margin-top: -60px;
opacity: 0;
-webkit-transition: all 0.05s ease-in-out;
transition: all 0.05s ease-in-out;
}
.form-group .legend-top input,
.form-group .legend-top select {
width: 100%;
}
.form-group .legend-top input:not(:placeholder-shown) ~ span,
.form-group .legend-top select:not(:placeholder-shown) ~ span {
opacity: 1;
font-size: 11.2px;
background-color: white;
color: #9FAAB7;
padding: 2px 4px;
margin: -58px 0 0 11.2px;
}
.form-group .legend-side {
display: -webkit-box;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: reverse;
flex-direction: row-reverse;
-webkit-box-align: start;
align-items: flex-start;
-webkit-box-pack: justify;
justify-content: space-between;
}
.form-group .legend-side input,
.form-group .legend-side select,
.form-group .legend-side span {
-webkit-box-flex: 1;
flex: 1 1 50%;
}
.form-group .legend-side input,
.form-group .legend-side select {
text-align: right;
width: 50%;
}
.form-group .legend-side select {
-moz-text-align-last: right;
text-align-last: right;
}
.form-group .legend-side span {
color: #9FAAB7;
}