How do I use css background-repeat property?



  • Also see: How do I use css background image property?

    The background-repeat can repeat an image across the entire width and height, disable repeating, or repeat vertically or horizontally.

    HTML Used.

    ...
        <div>
            <h1>Good Morning HTML</h1>
        </div>
    ...
    

    CSS code used.

    ...
     div {
               width: 500px;
               height: 500px;
               border: 5px solid blueviolet;
               margin: 100px auto;
               color: #fff;
               background-image: url(images/rose.jpeg)
               background-size: 100px;        
    ...
    

    The result is:

    eeebb470-b9e6-4463-93f7-0b14e7ad3eca-image.png

    Adding background-repeat: no-repeat; to the CSS disables repeating of the image and the result is:

    85dc24aa-6476-4212-8be0-34ab386f8df8-image.png

    Using background-repeat: repeat-x; or background-repeat: repeat-y; the images will be repeated horizontally or vertically.


Log in to reply
 

© Lightnetics 2024