利用css實現鼠標經過元素,下劃線由中間向兩邊展開

代碼如下:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>鼠標移入下劃線展開</title>
<style type="text/css">
#underline{
    width: 200px;
    height: 50px;
    background: #ddd;
    margin: 20px;
    position: relative;
}

#underline:after{
    content: "";
    width: 0;
    height: 1px;
    background: blue;
    position: absolute;
    top: 100%;
    left: 50%;
    transition: all .8s;
}

#underline:hover:after{
   left: 0%;
   width: 100%;
}
</style>

</head>

<body>

    <div id="underline"></div>

</body>

</html> 
發佈了122 篇原創文章 · 獲贊 40 · 訪問量 37萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章