image - ReactJS 中的图像着色

标签 image reactjs css inline-styles

所以我有这个 React 组件,我在其中传递背景图像和它应该通过 props 作为色调获得的颜色。它看起来像这样:

this.props.background = 'https://picsum.photos/650';
this.props.color = '#E74C3C';

<div style={{
                ...defaultStyle,
                background: 'url(' + this.props.background + '), linearGradient(' + this.props.color + ',' + this.props.color')'
            }}>

问题是它会抛出一个错误,指出无法编译。你能告诉我如何使用 css 内联样式应用色调吗?

最佳答案

您可以使用 rgba() 格式指定 LinearGradient,但最好使用不透明度设置较低的覆盖容器,并使用 props 传递色调颜色。我在 CodeSandBox 上使用覆盖构建了一个小示例 - View Sample

关于image - ReactJS 中的图像着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49498654/

相关文章:

python - Django-Oscar 图像错误

javascript - 将 .NET Core 环境传递给 React.JS 应用程序

reactjs - 如何使用 redux 中的 axios 库自动为发布到 API 服务器的数据生成唯一的 id

css - 有没有办法将页面内容定位在滚动条的下方或顶部?

css - 我可以删除已经呈现的 CSS 属性或声明吗?

java - 图片不可见水印

Python App Engine 上传图片内容类型

javascript - ImageFlow 显示默认宽高

reactjs - 克隆 moment js 对象

html - 在 CSS 中应用 font-face 的正确方法是什么?