Search code examples
htmlcssbackground-imagebootstrap-5

How to set background image using bootstrap 5


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


Solution

  • 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