Skip to content

Instantly share code, notes, and snippets.

@fatuk
Created January 24, 2025 19:50
Show Gist options
  • Select an option

  • Save fatuk/5c548cf324bc0459bf7893718069fcd7 to your computer and use it in GitHub Desktop.

Select an option

Save fatuk/5c548cf324bc0459bf7893718069fcd7 to your computer and use it in GitHub Desktop.
.input {
display: flex;
flex-direction: column;
justify-content: center;
padding: 20px;
border-top: solid 1px;
border-bottom: solid 1px;
height: 75px;
box-sizing: border-box;
}
.label {
font-size: 20px;
transition: all .3s;
}
.field {
font-size: 10px;
border: none;
background: transparent;
transition: all .3s;
}
.field:placeholder-shown {
height: 0;
overflow: hidden;
}
.label:has(+ .field:focus) {
font-size: 10px;
}
.field:focus {
outline: none;
height: auto;
font-size: 20px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<label class="input">
<div class="label">Label</div>
<input type="text" class="field" placeholder>
</label>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment