0

I am working on my website, I already added some images and now I want to set one background, main, which will be covered by the others, is it possible?

Entering background-image:url("myphoto.jpg") does not work for me. any ideas? Thanks!

Aslam
  • 9,204
  • 4
  • 35
  • 51
Luigi
  • 29
  • 1

4 Answers4

1

Give background class to the dive in which you want to apply background image. and give css as per below: This is how you can do:

    <div class="background"></div>

and style css would be:

.background{
background: url("myphoto.jpg") no-repeat center center;
background-repeat: no-repeat;
background-size: 100% 100%;
}
Hardi Shah
  • 343
  • 2
  • 15
0
   body {
      background: url("myphoto.jpg") no-repeat center center fixed; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }
  • @Luigi, the image url must be relative to the CSS file. For example, if your CSS file is in a subfolder relative to the html file, you may need to change the path to something like this: url("../myphoto.jpg") – adibble May 03 '17 at 07:23
0

@Hiren is correct, but you need to "Locate" the desired image, fx. if we say i have my www folder wich is my main folder, i have an index.html and a sub-folder called IMG, and inside there i got myphoto.jpg

then the following should be set as the url: url("img/myphoto.jpg")

body {
      background: url("https://www.qdtricks.net/wp-content/uploads/2016/05/hd-road-wallpaper.jpg") no-repeat center center fixed; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }
Thias
  • 11
  • 6
0
  background: url("{{asset('staticImage/wallpapers/wall_num10.jpg')}}") no-repeat center center fixed !important;

        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;