How to add background images in CSS code?

  1. celeb_prankster profile image58
    celeb_pranksterposted 6 years ago

    How to add background images in CSS code?

  2. profile image48
    springzposted 6 years ago

    You add a div to your stylesheet, like so:

    #mydiv{

    }

    Inside your div you write background-image and then the path to your image like so:

    #mydiv{
    background-image: url(images/myimage.jpg);
    }

    Then if you want your background image to repeat horizontally, you would do that like so:

    #mydiv{
    background-image: url(images/myimage.jpg);
    background-repeat: repeat-x;
    }

    Make sure you have a height and width on the div.

 
working