In CSS, you can use the background or background-image attribute to set the background image. The specific syntax format is "background-image:url('picture url');" or "background:url('picture url') ');".
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
In css, you can use the background or background-image attribute to set the background image.
The background-image property sets the background image of an element. The syntax format is as follows:
background-image:url('URL');
The background attribute is a shorthand attribute to set all background attributes in one statement. The attributes that can be set are:
background-color: Specify the background color to be used
background-position: Specify the position of the background image
background-size: Specify the size of the background image
background-repeat: Specify how to repeat the background image
background-origin: Specify the positioning area of the background image
background-clip: Specify the painting area of the background image
】Example: Set background image
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> body { background-image:url('paper.gif'); background-color:#cccccc; /*background:#cccccc url('paper.gif');*/ } </style> </head> <body> <h1>Hello World!</h1> </body> </html>
Rendering:
##For more programming-related knowledge, please visit: Programming Video
! !The above is the detailed content of How to set background image in css. For more information, please follow other related articles on the PHP Chinese website!