The CSS background properties define the background effects of an element.
The background attribute of CSS can define background effects for elements.
Set background color Set the background color
This example demonstrates how to set the background color for an element.
Instance:
The code is as follows: |
Copy code |
Body {background-color: yellow} H1 {background-color: #00ff00} H2 {background-color: transparent} P {background-color: rgb (250,0, 255 )}
|
Title 1
Title 2
Section
[You can modify some code before running it to view the effect]
Set an image as the background
This example demonstrates how to set an image as the background
Instance:
The code is as follows: |
Copy code |
Body { Background-image: url ('attachments/month_0612/52006129151936.jpg ') }
|
[You can modify some code before running it to view the effect]
Duplicate background image How to repeat a background image
This example demonstrates how to repeat a background image.
Instance:
The code is as follows: |
Copy code |
Body { Background-image: Url ('attachments/month_0612/52006129151936.jpg '); Background-repeat: repeat }
|
[You can modify some code before running it to view the effect]
Background image horizontal repetition How to repeat a background image only horizontally
This example demonstrates how to repeat a background image only horizontally.
Instance:
The code is as follows: |
Copy code |
Body { Background-image: Url ('attachments/month_0612/52006129151936.jpg '); Background-repeat: repeat-x }
|
[You can modify some code before running it to view the effect]
How to repeat a background image only vertically