Home > Web Front-end > CSS Tutorial > How to use css to make an image a background

How to use css to make an image a background

藏色散人
Release: 2022-12-30 11:12:26
Original
10552 people have browsed it

How to use css to make a picture a background: first create an HTML sample file; then add some p tags to the body; and finally use the background attribute in css to set the picture as the background.

How to use css to make an image a background

The operating environment of this tutorial: Windows 7 system, css3 version, DELL G3 computer.

Recommended: css video tutorial

You can use the background attribute in css to set the image as the background. background can set all background attributes in one statement.

The properties that can be set are: background-color, background-position, background-size, background-repeat, background-origin, background-clip, background-attachment and background-image.

Separate each value with a space, in no particular order. It is possible that only some of these values, such as background: #FF0000 URL (smiley.gif); are allowed.

Example:

<html>
<head>
<style type="text/css">
body
{ 
background: #ff0000 url(img/1.jpg) ; 
}
</style>
</head>
<body>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
<p>这是一些文本。</p>
</body>
</html>
Copy after login

The effect is as follows:

How to use css to make an image a background

The above is the detailed content of How to use css to make an image a background. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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