.demo1{ position: relative; text-decoration: none; font-size: 20px; color: #333; } .demo1:before{ content: ""; position: absolute; left: 50%; bottom: -2px; width: 0; height: 2px; background: #4285f4; transition: all .3s; } .demo1:hover:before{ width: 100%; left: 0; right: 0; }