简体   繁体   中英

how can I insert a background image in react for the whole screen?

I am developing a react web page.

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

<div style={ sectionStyle }></div>

This way, I tried to insert a background image. The background image is visualized only up to the amount of content available inside the div. I want to view it on the whole screen.

尝试height: "100vh"而不是100%

Try This way:

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

<div style={ sectionStyle }></div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM