I tried margin, top,left... and text-align but nothing work.
This is my code:
body {
background: #333;
}
.centered {
width: 550px;
height: 110px;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.group {
width: 100%;
height: 110px;
overflow: hidden;
position: relative;
}
label {
position: absolute;
top: 36.6666666667px;
color: #2196f3;
font: 400 36.6666666667px Roboto;
cursor: text;
transition: 0.3s ease;
}
input {
display: block;
width: 100%;
padding-top: 36.6666666667px;
border: none;
border-radius: 0;
color: white;
background: #333;
font-size: 36.6666666667px;
transition: .3s ease;
}
input:valid ~ label {
top: 0;
font: 700 22px Roboto;
}
input:focus {
outline: none;
}
input:focus ~ label {
top: 0;
font: 700 22px Roboto;
}
input:focus ~ .bar:before {
transform: translateX(0);
}
.bar {
background: #2196f3;
content: '';
width: 550px;
height: 3.6666666667px;
transition: .3s ease;
position: relative;
}
<div class="centered">
<div class="group">
<input type="text" id="name" required="required"/>
<label for="name">Name</label>
<div class="bar"></div>
</div>
</div>