CSS让视频,图片背景透明化

mix-blend-mode混合模式中有一种混合模式名为滤色,单词是screen,其有一个很有意思的特性表现,那就是黑色和其它元素进行混合的时候表现为透明。

在这里插入图片描述

<div class="figure">
	<img src="https://source.unsplash.com/VW8MUbHyxCU/1920x1080" alt="" class="image">
	<h1 class="text">Fade-in Text</h1>
</div>
.figure {
	position: relative;
	height: 100vh;
	overflow: hidden;
}

.image {
	position: absolute;
	width: 100%;
	height: 100%;
	object-fit: cover;
	z-index: -1;
	transform: scale(1.8);
	animation: scaleImage 5s ease-out forwards;
}

.text {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100%;
	font-family: 'Roboto', Arial, sans-serif;
	font-size: calc(10px + 8vw);
	font-weight: 700;
	line-height: 1.2;
	letter-spacing: 0.05em;
	white-space: nowrap;
	text-transform: uppercase;
	color: #fff;
	background-color: #000;
	mix-blend-mode: multiply;
	opacity: 0;
	margin: 0;
	animation: fadeInText 3s 2s ease-out forwards;
}

@keyframes scaleImage {
	100% {
		transform: scale(1);
	}
}

@keyframes fadeInText {
	100% {
		opacity: 1;
	}
}

视频也是也可以直接设置,只要把我们的视频背景色设置为黑色,同时设置如下CSS即可:

video {
    mix-blend-mode: screen;
}
  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值