add background image in react with bootstrap

if there s someone who can help me to fix this problem. i can t add a background image to the Navbar in react.js i will be thankful if there s someone who can help me.

import React, { Component } from 'react';
import Navbar from './Navbar';
import './navbar.css';

    class App extends Component {
  render() {
    return (
      <div className="logo">

      <div>
        <Navbar/>
      </div>


      </div>
    );
  }
}

export default App;

<--Style--!>
.logo{

    background-image: url('./header.jpg');

}

First you have to import the pic you want to add

import LogoImage from './header.jpg';

var sectionStyle = {
   backgroundImage: `url(${LogoImage})`
}

 class App extends Component {
  render() {
    return (

      <div style={sectionStyle}>

      <div>
        <Navbar/>
      </div>


      </div>
    );
  }
};

I hope this will give you an Idea on how to solve this problem

How To Set Background Image In React ?, you can understand a concept of react bootstrap background image. Follow bellow tutorial step of react set background image to div. export default App; I hope it can help you React Background Image React Background Image - Bootstrap 4 & Material Design. React Bootstrap background image is an illustration chosen by a user placed behind all other objects on the website. It may be full or partially visible.

You can't put style inside a react.js Component. You can solve this issue in two ways

  1. You can put it inside your navbar.css file
  2. You can put it as react inline css like below

    import React, { Component } from 'react';
    import Navbar from './Navbar';
    import './navbar.css';
    import image from "./header.jpg";
    
    class App extends Component {
     render() {
      return (
        <div className="logo" style={{backgroundImage: `url(${image}` }}>
         <div>
           <Navbar/>
         </div>
        </div>
      );
     }
    }
    export default App;
    

Responsive Proportional Images (React), How do you make an image responsive in react JS? Background image Bootstrap background image. A Bootstrap background image is an illustration chosen by a user that is placed behind all the other objects on the website. It may be full or partially visible.

I would recommend creating a separate css file and importing that, then referencing your class name using className=!

How to add Background Image to Bootstrap 4 Jumbotron in React , How to add Background Image to Bootstrap 4 Jumbotron in React / React Bootstrap Duration: 2:32 Posted: 18 Mar 2020 In the above example first, we imported car image from the images folder then we added it to the div element using backgroundImage css property. Setting image using external css If you don’t like adding background images using inline styles we can also add using external css styles.

React Background Image, React Bootstrap background image is an illustration chosen by a user placed Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut  I'm trying to put a background image on my form (like behind the text and inputs, just like a background image of my web site), using the Bootstrap framework but the image appears at the bottom and I want it inside the "container". My code is something like this:

Images, Sets image shape as thumbnail. bsPrefix. string. 'img'. Change the underlying component CSS base class name and modifier class names prefix  1. Responsive images Images in Bootstrap are made responsive with .img-fluid. max-width: 100%;and areheight: auto; applied to the image so that it scales with the parent element. The Bootstrap background image property sets one or more background images for an element.

How to set a Background Image in React, If you don't like adding background images using inline styles we can also add using external css styles. Example: App.js. import React from '  React Bootstrap is the most popular option that strives for complete parity with Bootstrap. reactstrap is also a good choice for projects looking for smaller builds at the expense of some features. Each project's respective documentation site has detailed instructions for installing and using them. Both depend on the Bootstrap css file so

Comments
  • Try adding a height / width as well.
  • @khaliloosben you have to put the image inside url.
  • @user1434285 i did it before but the same problem