How to set background image in css

青灯夜游
Release: 2023-01-03 09:30:57
Original
16725 people have browsed it

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');
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!