Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AGmakonts/903dbcac776e1428741435a6a08c585d to your computer and use it in GitHub Desktop.
Save AGmakonts/903dbcac776e1428741435a6a08c585d to your computer and use it in GitHub Desktop.
Animated label for rounded button
<div>
<label for="name">
<input name="name" id="name" placeholder="name">
<span>Username</span>
</label>
</div>
div {
width: 400px;
padding: 40px;
}
* {
transition: all 200ms ease;
}
label {
display: flex;
flex-direction: column-reverse;
}
span {
font-weight: 700;
}
input, span {
font-family: Raleway;
font-size: 15px;
position:relative;
cursor: text;
}
input:focus {
border-color: #376969
}
input:focus + span {
color: #376969
}
input:focus + span, input:not(:placeholder-shown) + span {
top:0;
}
input::-webkit-input-placeholder {
color: white;
}
span {
margin-left: 26px;
top: 27px;
margin-bottom: 10px;
}
input {
font-weiht: 300;
outline: none;
height: 30px;
appearance: none;
-webkit-appearance: none;
border: none;
border-bottom: 1px solid black;
border-left: 1px solid black;
border-bottom-left-radius: 24px;
box-sizing: border-box;
padding: 0 0 12px 23px
}
<link href="https://fonts.googleapis.com/css?family=Raleway:300,500,700" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment