skip to Main Content

I have been trying to set a background image for my website using bootstrap 5 but it is not showing

I use external CSS to set the background image but it is not working
The code is:

    body {
background-image: url(images/bgr.jpeg);
}

I will like to know what I can do to set the background image for my website correctly. Thanks

3

Answers


  1. try surrounding the source in quotes so:

       body {
    background-image: url("images/bgr.jpeg");
    }
    

    top result

    Login or Signup to reply.
  2. You can add background image using inline CSS, I hope it’s better out of external CSS

    for example

    <container style="background-image: url(images/bgr.jpeg); width: 100%; height: 100vh; background-repeat: no-repeat; background-size: cover;">
    // your next code is here
    </container>
    

    Remember it, we don’t need to use use "images/bgr.jpeg" for our path with have to use just path name images/bgr.jpeg

    Also we can set width: 100%; height: 100vh; etc

    Login or Signup to reply.
  3. i think you need to add class on body in html like this <body class="bg"> then call it in css

    .bg {background-image: url("images/bgr.jpeg");}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search