<div class="wrapper">
  <div class="container">
    <input id="name" type="text" placeholder="Name">
    <label for="name">Name</label>
  </div>
</div>
.wrapper {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
.container {
  position: relative;
}
label {
  position: absolute;
  left: 0;
  padding: 1rem 0.75rem;
  transition: all 0.15s ease-out;
}
input {
  min-width: 15rem;
  padding: 1.5rem 0.8rem 0.5rem;
  &:focus,
  &:not(:placeholder-shown) {
    + label {
      color: rgba(0, 0, 0, 0.7);
      transform: translate(-0.1rem, -0.8rem) scale(0.8);
    }
  }
  &::placeholder {
    color: transparent;
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.