文本/链接

CSS3鼠标悬停文字幻影动画特效

阿里云


这是一款 CSS3 鼠标悬停文字幻影动画特效。该特效利用 before 和 after 伪元素来制作当鼠标悬停在超链接文本上的时候的幻影效果。

使用方法

在页面中引入 bootstrap.css、jquery 和 photoviewer.js 文件。

也想出现在这里?联系我们
创客主机
  1. <link href="dist/bootstrap.css" rel="stylesheet">

HTML 结构

在页面中添加一个<a>元素,并设置它的 data-hover 属性和它的显示文字相同。

  1. <a href="#" class="link" data-hover="鼠标移过来">鼠标移过来</a>

CSS 样式

然后通过下面的 CSS 样式来制作鼠标悬停在超链接文字上的幻影动画特效。

  1. .link{
  2.     color: #555;
  3.     font-family: 'Courgette', cursive;
  4.     font-size: 30px;
  5.     line-height: 25px;
  6.     display: inline-block;
  7.     position: relative;
  8.     z-index: 1;
  9.     transition: all 0.5s;
  10. }
  11. .link:hover{ color: transparent; }
  12. .link:before,
  13. .link:after{
  14.     content: attr(data-hover);
  15.     white-space: nowrap;
  16.     position: absolute;
  17.     left: 0;
  18.     top: 0;
  19.     height: 100%;
  20.     width: 100%;
  21.     transition:all 0.5s;
  22. }
  23. .link:after{
  24.     color: #1da493;
  25.     opacity: 0;
  26.     left: -10px;
  27. }
  28. .link:hover:before{
  29.     left: 15px;
  30.     opacity: 0;
  31. }
  32. .link:hover:after{
  33.     left: 0;
  34.     opacity: 1;
  35.     transition-delay:0.1s;
  36. }
  37. @media only screen and (max-width: 990px){
  38.     .link span{ font-size: 20px; }
  39. }
  40. @media only screen and (max-width: 767px){
  41.     .link{ margin: 0 0 30px; }
  42. }

CSS3 鼠标悬停文字幻影动画特效

已有 319 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(0)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!