Javascript 如何在react中为整个屏幕插入背景图像?

Javascript 如何在react中为整个屏幕插入背景图像?,javascript,reactjs,express,Javascript,Reactjs,Express,我正在开发一个react网页 var sectionStyle = { width: "100%", height: "100%", backgroundImage: "url(" + background + ")" }; <div style={ sectionStyle }></div> var sectionStyle={ 宽度:“100%”, 高度:“100%”, 背景图片:“url(“+background

我正在开发一个react网页

 var sectionStyle = {
      width: "100%",
      height: "100%",
      backgroundImage: "url(" +  background  + ")"
    };

<div style={ sectionStyle }></div>
var sectionStyle={
宽度:“100%”,
高度:“100%”,
背景图片:“url(“+background+”)
};
这样,我尝试插入一个背景图像。背景图像仅在div中可用的内容量内可见。 我想在整个屏幕上查看它

尝试高度:“100vh”而不是100%

尝试高度:“100vh”而不是100%

尝试以下方法:

 var sectionStyle = {
      width: 100vh,
      height: 100vh,
      backgroundImage: "url(" +  background  + ")"
    };

<div style={ sectionStyle }></div>
var sectionStyle={
宽度:100vh,
高度:100vh,
背景图片:“url(“+background+”)
};
尝试以下方法:

 var sectionStyle = {
      width: 100vh,
      height: 100vh,
      backgroundImage: "url(" +  background  + ")"
    };

<div style={ sectionStyle }></div>
var sectionStyle={
宽度:100vh,
高度:100vh,
背景图片:“url(“+background+”)
};

现在它使用视口单位。这些并不总是得到支持,尤其是在旧版本的android和internet explorer中。因此,根据您的项目范围谨慎使用。现在使用视口单位。这些并不总是得到支持,尤其是在旧版本的android和internet explorer中。因此,根据您的项目范围谨慎使用。