CSS伪类简易动画条(两边)
HTML代码:
<body>
<p>Home</p>
<p>Item</p>
<p>Outer</p>
</body>
CSS代码:
*{margin: 0;padding: 0;}
p{
font-family: fantasy;
font-size: 22px;
font-weight: 600;
padding: 20px 0;
margin-left:100px;
display: inline-block;
position: relative;
cursor:pointer;
}
p:before{
content: "";
width:50%;
height: 2px;
background: #FCBAD3;
position: absolute;
bottom: 0;
left:0;
-webkit-transition:.5s ;
}
p:after{
content: "";
width:50%;
height: 2px;
background: #FCBAD3;
position: absolute;
bottom: 0;
right:0;
-webkit-transition:.5s ;
}
p:hover:before,
p:hover:after{
width:200%;
}
动画效果如下: