How to set images not to repeat in css

醉折花枝作酒筹
Release: 2023-01-05 16:08:57
Original
5635 people have browsed it

css can use the "background-repeat" attribute to set the image not to repeat, the syntax is "background-repeat:no-repeat"; this attribute sets whether and how to repeat the background image, when the value is "no-repeat" , indicating that the background image is only displayed once.

How to set images not to repeat in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

Background-repeat attribute introduction:

The background-repeat attribute defines the tiling mode of the image.

Repeat starting from the original image, which is defined by background-image and placed according to the value of background-position.

Attribute value:

  • repeat Default. The background image will repeat vertically and horizontally.

  • repeat-x The background image will repeat horizontally.

  • repeat-y The background image will repeat vertically.

  • no-repeat The background image will be displayed only once.

  • inherit specifies that the setting of the background-repeat attribute should be inherited from the parent element.

Example:

<html>
<head>
<style type="text/css">
body
{ 
background-image: 
url(/i/eg_bg_03.gif);

}
</style>
</head>
<body>
</body>
</html>
Copy after login

Rendering:

How to set images not to repeat in css

css set the image not to repeat

<html>
<head>

<style type="text/css">
body
{ 
background-image: 
url(/i/eg_bg_03.gif);
background-repeat: no-repeat
}
</style>

</head>

<body>
</body>
</html>
Copy after login

Rendering:

How to set images not to repeat in css

Recommended learning: css video tutorial

The above is the detailed content of How to set images not to repeat in css. 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