html+css实现简单的文字上色效果

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>文字上色效果</title>
</head>
<style type="text/css">
body,p,dl,dd,ul,ol,li,div,h1,h2,h3,h4,h5,h6,form,input,table,tr,td,fieldset,figure{
	margin:0;
	padding:0;
}
.box{
	width:310px;
	height:100%;
	border:1px solid black;
	margin:80px auto;
	padding-left:10px;
	padding-top: 10px;
	padding-bottom:10px;
}
.box p{
	height:35px;
	font-size: 16px;
	line-height:35px;
	position: relative;
	opacity: 0;
	display: table;	
}
.box p span{
	color:#d32af7;
	border-bottom: 3px solid #d32af7;
	position: absolute;
	top:0;
	left:0px;
	width:0;
	white-space: nowrap;
	overflow: hidden;
}
.box p:nth-child(1){
	animation: cx 2s linear forwards;
}
.box p:nth-child(1) span{
	animation: ys 2s 2s linear forwards;
}
.box p:nth-child(2){
	animation: cx 2s 4s linear forwards;
}
.box p:nth-child(2) span{
	animation: ys 2s 6s linear forwards;
}
.box p:nth-child(3){
	animation: cx 2s 8s linear forwards;
}
.box p:nth-child(3) span{
	animation: ys 2s 10s linear forwards;
}
.box p:nth-child(4){
	animation: cx 2s 12s linear forwards;
}
.box p:nth-child(4) span{
	animation: ys 2s 14s linear forwards;
}
.box p:nth-child(5){
	animation: cx 2s 16s linear forwards;
}
.box p:nth-child(5) span{
	animation: ys 2s 18s linear forwards;
}
.box p:nth-child(6){
	animation: cx 2s 20s linear forwards;
}
.box p:nth-child(6) span{
	animation: ys 2s 22s linear forwards;
}
.box p:nth-child(7){
	animation: cx 2s 24s linear forwards;
}
.box p:nth-child(7) span{
	animation: ys 2s 26s linear forwards;
}
.box p:nth-child(8){
	animation: cx 2s 28s linear forwards;
}
.box p:nth-child(8) span{
	animation: ys 2s 30s linear forwards;
}
@keyframes cx{
	0%{
		opacity: 0;
		transform: translateY(-100%);
	}
	100%{
		opacity: 1;
		transform: translateY(0);
	}
}
@keyframes ys{
	0%{
		width:0;
	}
	100%{
		width:100%;
	}

</style>
<body>
	<div class="box">
		<p>想要问问你敢不敢<span>想要问问你敢不敢</span></p>
		<p>像你说过那样的爱我<span>像你说过那样的爱我</span></p>
		<p>想要问问你敢不敢<span>想要问问你敢不敢</span></p>
		<p>像我这样为爱痴狂<span>像我这样为爱痴狂</span></p>
		<p>想要问问你敢不敢<span>想要问问你敢不敢</span></p>
		<p>像你说过那样的爱我<span>像你说过那样的爱我</span></p>
		<p>像我这样为爱痴狂<span>像我这样为爱痴狂</span></p>
		<p>到底你会怎么想<span>到底你会怎么想</span></p>
	</div>
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值