需求
一张大背景图,然后里面文字内容块部分实现透明度渐变
思路
background-image
linear-gradient
rgba
效果图
上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>透明度渐变</title>
<style>
#bg{
width: 200px;
height: 400px;
background: #000;
}
#current{
width: 200px;
height: 200px;
background: linear-gradient(rgba(255,255,255,1),rgba(255,255,255,.3));
color: burlywood;
line-height: 200px;
text-align: center;
}
</style>
</head>
<body>
<div id="bg">
<div id="current">透明度渐变的,我儿豁</div>
</div>
</body>
</html>