Home  >  Article  >  Web Front-end  >  How to set background image in css

How to set background image in css

青灯夜游
青灯夜游Original
2021-03-22 11:39:1316701browse

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') ');".

How to set background image in css

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

  • ##background- attachment: Sets whether the background image is fixed or scrolls with the rest of the page.

  • background-image: Specify one or more background images to use

  • ##[Recommended tutorial:
CSS video tutorial

Example: Set background image

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
body 
{
	background-image:url(&#39;paper.gif&#39;);
	background-color:#cccccc;
	
	/*background:#cccccc url(&#39;paper.gif&#39;);*/
}
</style>
</head>

<body>
<h1>Hello World!</h1>
</body>

</html>

Rendering:


##For more programming-related knowledge, please visit: How to set background image in cssProgramming 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn