首页 > Day After Day > 纯 CSS3 实现鼠标移上链接的卡拉OK字幕效果

纯 CSS3 实现鼠标移上链接的卡拉OK字幕效果

2016年8月25日 发表评论 阅读评论

直接上 CSS 代码

a {
    display: inline-block;
    color: #404040;
    text-decoration: none;
    overflow: hidden;
    position: relative;
}

a::before {
	content: attr(data-letters);
	color: #f34540;
	width: 0;
	background: #fff;
	overflow: hidden;
	position: absolute;
	top: 0;
	left: 0;
	z-index: 2;
	white-space: nowrap;
	transition: width .5s;
}

a:hover::before{
	width: 100%;
	transition: width .5s;
}

然后就是 HTML 范例

测试一下文字的渐变特效

分类: Day After Day 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.