如何在React中使用样式在特定div中设置线性渐变和背景图像 [英] How to set both linear-gradient and background image in a specific div using styles in React

查看:39
本文介绍了如何在React中使用样式在特定div中设置线性渐变和背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Reactsjs中的样式在特定的div上设置线性渐变以及背景图像

I need to set linear-gradient as well as the background image on a specific div using styles in Reactsjs

我能够获得它们中的任何一个,我的意思是说图像或线性渐变,但不能同时显示

I am able to get either of them, I mean to say either image or linear-gradient but not both at the same time

图像将与线性渐变重叠

我尝试了以下解决方案:

I tried below solution :

 leftAdArea: {
      width: 380,
      height: 580,
      background: 'url(https://www.mahealthcare.com/assets/images/clinic/NursePhone.jpg) no-repeat , linear-gradient(135deg, #50A684 30%, #115E67 90%)',
      }

建议我做这种事情,以便可以在图像上使用图像以及线性渐变

Suggest me to to do this kind of stuff where I can use the image as well as linear-gradient on an image

谢谢

推荐答案

leftAdArea: {
  width: 380,
  height: 580,
  background:`url(obj.image) no-repeat, linear-gradient(135deg, #50A684 30%, #115E67 90%)`,
}

使用反引号代替qoutes

used backtick instead of qoutes

这篇关于如何在React中使用样式在特定div中设置线性渐变和背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆