css实现烟雾效果(css制作汽车尾气排放效果)

前段时间项目要求做一个汽车尾气排放的特效,在网上看到一个文字变烟的效果,经过修改终于有汽车尾气排放的效果了,感动ing~
效果网址:http://chechao.cloudqz.com?share_uid=3(使用微信浏览器打开)
注意:看汽车排气位置
请添加图片描述

代码部分
html:

<body>
	<p class="smoke">
		这里直接输入文字如:烟烟烟烟烟烟烟烟烟烟烟烟烟烟烟
	</p>
</body>
<!--这里要在body外加一段js,可以使单个文字飘起来-->
<script>
	var txt = document.querySelector(".smoke");
	txt.innerHTML = txt.textContent.replace(/\S/g,"<span class='smoke_p'>$&</span>");
	var arr = document.querySelectorAll(".smoke_p");
	arr.forEach(function(temp){
		temp.classList.add('move');
	})
</script>

css:

/* 烟 */
.smoke{
	position: absolute;
	bottom: 93px;
	right: calc(-2%);
	/*这里要定义好div的大小,决定烟团的大小*/
	width: 120px;
	height: 80px;
	text-indent: 2em;
	/*文字颜色,即烟的颜色*/
	color: rgb(255, 255, 255);
	font-size: 18px;
	cursor: pointer;
	user-select: none;
	text-align: justify;
}
.smoke span{
	position: relative;
	display: inline-block;
	transform-origin: bottom;
	text-indent: 0;
}
.smoke .move{        
	animation: up 3s linear infinite;
}
@keyframes up{
	0%{
	opacity: 0.1;
	/*这里使用高斯吗,模糊+透明度,使文字糊掉*/
	filter: blur(10px);
	/* transform: translate(600px,-100px) rotate(360deg) scale(5); */
	}
	20%{
		opacity: 0.5;
		filter: blur(5px);
	}
	50%{
		opacity: 0.8;
		filter: blur(10px);
	}
	100%{
		opacity: 0.2;
		filter: blur(20px);
		transform: translate(100px,-100px) rotate(360deg) scale(3);
	}
}

js

//因为这里刚进页面不显示  所以延时显示烟雾
$(".smoke").hide();
setTimeout(function() {
	$(".smoke").fadeIn();
}, 2000);

好了,这是小编的一些开发思路,如果各位大佬有更好的方法,麻烦在下方评论或者私聊小编哦~
让小编一起学习。

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值