Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
566 views
in Technique[技术] by (71.8m points)

reactjs - 如何在React + bootstrap中添加背景图片?(How do I add a background image in React+bootstrap?)

I have been trying to add a background image to my webpage.

(我一直在尝试向我的网页添加背景图片。)

This is how I am currently trying to do it but it doesn't seem to work.

(这是我目前正在尝试执行的操作,但似乎没有用。)

in my App.js file:

(在我的App.js文件中:)


import React from 'react';
import './App.css';
import NavBar from './Components/NavBar';
import LandingPageImage from './Components/LandingPageImage';


function App() {
  return (
    <div className="App">
      <div className="Screen" >
        <NavBar/>
        <LandingPageImage/>
      </div>
    </div>
  );
}

export default App;

in my App.css file:

(在我的App.css文件中:)

.Screen {
 background-image: url("https://images.unsplash.com/photo-1536514498073-50e69d39c6cf?ixlib=rb-1.2.1&auto=format&fit=crop&w=1951&q=80");
}

This doesnot seem to work.

(这似乎不起作用。)

I was expecting to see the background image on the Screen div but nothing shows up.

(我原本希望在Screen div上看到背景图像,但是什么也没有显示。)

  ask by Rahul Chatterjee translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...