css - 背景图像上的内联线性渐变
问题描述
我有一张带有轻微黑色线性渐变的图像,以提高可读性
.hero-image {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("./images/slideshow/2.jpg");
但是我使用的幻灯片只接受具有内联backgroundImage
属性的 div
<div
className="slideshow-image"
style={{ backgroundImage: `url(${slideshow2})`, repeat: "no-repeat" }}
>
问题是我无法使用内联样式添加图像之前的线性渐变。
//attempt 1
const backgroundStyle = {
backgroundImage: `url(${slideshow1})`,
linearGradient: "(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",
};
// attempt 2
style={{
linearGradient: "(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))",
backgroundImage: `url(${slideshow1})`,
repeat: "no-repeat",
}}
//attempt 3
.slideshow-image {
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5));
这些都不会在图像上显示任何内容。接下来我可以尝试什么来实现这一目标?
解决方案
推荐阅读
- python-3.x - Flask 文件上传到 Azure Data Lake Store
- docker - 正确控制 Docker 映像的版本
- matlab - 如何在 ode 求解器中的每个时间步使用矩阵的一个值
- scrapy - scrapy 307 重定向到同一页面
- python - 将 alt.Chart() 与来自 google drive url 链接的数据一起使用
- java - 通过 SSL 连接的精简 JRE11 需要什么?
- javascript - Node 和使用节点模块的项目之间有什么联系?
- comsol - Comsol 电阻加热线圈模拟
- javascript - 如何减慢javascript中的循环
- javascript - 如果值有逗号,则循环并将对象字符串值转换为对象