300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > html语言鼠标悬停特效 CSS3鼠标悬停文字幻影动画特效

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

时间:2019-05-18 07:28:44

相关推荐

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

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

使用方法

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

HTML结构

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

鼠标移过来

CSS样式

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

.link{

color: #555;

font-family: 'Courgette', cursive;

font-size: 30px;

line-height: 25px;

display: inline-block;

position: relative;

z-index: 1;

transition: all 0.5s;

}

.link:hover{ color: transparent; }

.link:before,

.link:after{

content: attr(data-hover);

white-space: nowrap;

position: absolute;

left: 0;

top: 0;

height: 100%;

width: 100%;

transition:all 0.5s;

}

.link:after{

color: #1da493;

opacity: 0;

left: -10px;

}

.link:hover:before{

left: 15px;

opacity: 0;

}

.link:hover:after{

left: 0;

opacity: 1;

transition-delay:0.1s;

}

@media only screen and (max-width: 990px){

.link span{ font-size: 20px; }

}

@media only screen and (max-width: 767px){

.link{ margin: 0 0 30px; }

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。