Set a background-image for the <body> element:
![]() Example
Download a version that suits your needs: Owl Carousel - 2.3.4 - Distributed version - compiled and minified. Javascript, images and CSS included. Owl Carousel Source - 2.3.4 - Source files including this documentation. All wrapped in Grunt project. Files included.
body { Try it Yourself »
background-image: url('paper.gif'); background-color: #cccccc; } Example
Set two background images for the <body> element:
![]()
body { Try it Yourself »
background-image: url('img_tree.gif'), url('paper.gif'); background-color: #cccccc; }
More 'Try it Yourself' examples below.
Definition and Usage
The
background-image property sets one or more background images for an element.
By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.
Tip: The background of an element is the total size of the element, including padding and border (but not the margin).
Tip: Always set a background-color to be used if the image is unavailable.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Note: IE8 and earlier do not support multiple background images.
CSS SyntaxProperty Values
More ExamplesExample
Sets two background images for the <body> element. Let the first image appear only once (with no-repeat), and let the second image be repeated:
body { Try it Yourself »
background-image: url('img_tree.gif'), url('paper.gif'); background-repeat: no-repeat, repeat; background-color: #cccccc; } Example
Use different background properties to create a 'hero' image:
.hero-image { Try it Yourself »
background-image: url('photographer.jpg'); /* The image used */ background-color: #cccccc; /* Used if the image is unavailable */ height: 500px; /* You must set a specified height */ background-position: center; /* Center the image */ background-repeat: no-repeat; /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ } Example
Sets a linear-gradient (two colors) as a background image for a <div> element:
#grad1 { Try it Yourself »
height: 200px; background-color: #cccccc; background-image: linear-gradient(red, yellow); } Example
Sets a linear-gradient (three colors) as a background image for a <div> element:
#grad1 { Try it Yourself »
height: 200px; background-color: #cccccc; background-image: linear-gradient(red, yellow, green); } Example
The repeating-linear-gradient() function is used to repeat linear gradients:
#grad1 { Try it Yourself »
height: 200px; background-color: #cccccc; background-image: repeating-linear-gradient(red, yellow 10%, green 20%); } Example
Sets a radial-gradient (two colors) as a background image for a <div> element:
#grad1 { Try it Yourself »
height: 200px; background-color: #cccccc; background-image: radial-gradient(red, yellow); } Example
Sets a radial-gradient (three colors) as a background image for a <div> element:
#grad1 { Try it Yourself »
height: 200px; background-color: #cccccc; background-image: radial-gradient(red, yellow, green); } Example
The repeating-radial-gradient() function is used to repeat radial gradients:
#grad1 { Try it Yourself »
height: 200px; background-color: #cccccc; background-image: repeating-linear-gradient(red, yellow 10%, green 20%); } Related Pages
CSS tutorial: CSS Background, CSS Backgrounds (advanced), CSS Gradients
HTML DOM reference: backgroundImage property
If your download does not start automatically, please click the filename below.
File Information:You can verify the integrity of the download with the SHA-1 or SHA-256 checksums and be sure you have a genuine copy by checking the GPG signature against the provided public key.
File hashes are mirrored on GitHub. Installation Instructions
We provide an installation guide within our documentation.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |