Html 向图像添加黑色透明度
这是我的网页的外观: 我使用以下图像作为背景: 如何在图像上设置黑色透明覆盖,因此它看起来如下所示: 以下是我的html和CSS代码:Html 向图像添加黑色透明度,html,css,frontend,Html,Css,Frontend,这是我的网页的外观: 我使用以下图像作为背景: 如何在图像上设置黑色透明覆盖,因此它看起来如下所示: 以下是我的html和CSS代码: <!DOCTYPE html> <html> <head> <title>Background Image</title> <meta charset="utf-8"></meta> <meta na
<!DOCTYPE html>
<html>
<head>
<title>Background Image</title>
<meta charset="utf-8"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1" ></meta>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<style type="text/css">
body{
margin-top: 53px;
}
.jumbotron {
background-image: url("background1.jpg");
text-align: center;
height:522px;
background-size: cover;
}
</style>
<body>
<section id="page-top">
<div class="jumbotron">
<p data-aos="zoom-out" data-aos-delay="500" style="font: 120px Verdana,sans-serif; margin-top: 35px; color: black; animation-duration: 2s; animation-iteration-count:infinite; animation-delay: 1s;" class="lead pulse mb-5 green pb-5 aos-init aos-animate">Matt Williams</p>
<p data-aos="zoom-out" data-aos-delay="500" style="font: 20px Georgia,serif;font-style:italic; line-height: 1.6; color:white;animation-duration:2s;animation-iteration-count:infinite; animation-delay:1s;" class="lead pulse mb-5 lightGreen pb-5 aos-init aos-animate d-none d-lg-block">Lorem Ipsum.<br>Lorem Ipsum.</p>
</div>
</section>
</body>
</html>
背景图像
身体{
边缘顶端:53px;
}
琼伯伦先生{
背景图片:url(“background1.jpg”);
文本对齐:居中;
高度:522px;
背景尺寸:封面;
}
Matt Williams
Lorem Ipsum。
Lorem Ipsum
您可以在url背景之前添加透明渐变:
.jumbotron{
背景图像:线性渐变(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(“background1.jpg”);
}
例如:
正文{
背景图像:线性渐变(0度,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(https://picsum.photos/id/896/640/480);
}
您可以在url背景之前添加透明渐变:
.jumbotron{
背景图像:线性渐变(0deg,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(“background1.jpg”);
}
例如:
正文{
背景图像:线性渐变(0度,rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(https://picsum.photos/id/896/640/480);
}