首页 > 开发 > CSS > 正文

CSS3绘制有活力的链接下划线

2024-07-11 08:32:37
字体:
来源:转载
供稿:网友

链接下划线是非常常见的一种样式,最近做了一个非常简单的视觉效果,非常不错,完整代码查看。

XML/HTML Code复制内容到剪贴板
  1. <!DOCTYPE html>   <html>  
  2. <head>     <meta charset="gb2312">  
  3.   <meta name="viewport" content="width=device-width">     <title>JS Bin</title>  
  4. <style>   body{   
  5.   background-color: #000;    }   
  6.    h2{    
  7.   text-align: center;      margin-top: 100px;   
  8. }      
  9. h2 > a {      position: relative;   
  10.   color: #FFF;      text-decoration: none;   
  11.   padding-bottom: 5px;    }   
  12.    h2 > a:hover {   
  13.   color: #FFF;    }    
  14.    h2 > a:before {   
  15.   content: "";      position: absolute;   
  16.   width: 100%;      height: 2px;   
  17.   bottom: 0;      left: 0;   
  18.   background-color: #FFF;      visibility: hidden;   
  19.   -webkit-transform: scaleX(0);      transform: scaleX(0);   
  20.   -webkit-transition: all 0.3s ease-in-out 0s;      transition: all 0.3s ease-in-out 0s;   
  21. }      
  22. h2 > a:hover:before {      visibility: visible;   
  23.   -webkit-transform: scaleX(1);      transform: scaleX(1);   
  24. }    </style>  
  25. </head>   <body>  
  26.    <h2>        <a href="/">悬停在我上面</a>  
  27.    </h2>   </body>  
  28. </html>     
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表