body { margin: 0; min-height: 100vh; display: grid; place-items: center; background: #f4f3ef; font: 16px system-ui, sans-serif; }
form { display: grid; gap: 18px; width: 320px; }
.field { position: relative; }
.field input { width: 100%; box-sizing: border-box; padding: 22px 14px 8px; border: 1px solid #cfcbc2; border-radius: 12px; font: inherit; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.field label { position: absolute; left: 14px; top: 15px; color: #7d7f86; pointer-events: none; transform-origin: left top; transition: transform .15s, color .15s; }
.field input:focus { border-color: #3f6b00; box-shadow: 0 0 0 3px #e8f3d2; }
.field input:focus + label, .field input:not(:placeholder-shown) + label { transform: translateY(-9px) scale(.75); color: #3f6b00; }
.field input:not(:placeholder-shown):invalid { border-color: #b42318; }Usage
The input needs a placeholder (a single space works). Label must follow the input.