div { width:800px; margin:200px auto; border:1px solid red; text-align:center; } input { width:100%; height:40px; border:1px solid #dbdbdb; outline:none; font-size:20px; text-indent:10px; } label { position:relative; width:400px; margin:10px auto; display:inline-block; } label:after { content:""; display:inline-block; width:0; height:2px; background:red; transition:width 1s; position:absolute; bottom:1px; left:1px; } .active:after { width:calc(100% - 2px) }