Home > Web Front-end > CSS Tutorial > How to set image tiling mode in css

How to set image tiling mode in css

青灯夜游
Release: 2021-11-10 17:17:22
Original
17025 people have browsed it

In css, you can use the background-repeat attribute to set the image tiling method. When the value is "repeat", the background can be completely tiled. When it is "repeat-x", it can be tiled horizontally. When it is "repeat" -y" can be tiled vertically, and "no-repeat" can not be tiled (the image will only be displayed once).

How to set image tiling mode in css

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

In css, you can use the background-repeat attribute to set the image tiling method.

The background-repeat attribute defines the tiling mode of the image and sets whether and how to repeat the background image.

The background-repeat attribute can set four tiling modes:

1. When the value is "repeat", the background can be completely tiled

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

<!DOCTYPE html>
<html>
	<head>
		<style>
			div {
				width: 500px;
				height: 500px;
				border: 2px solid red;
				background-image: url(img/nz.png);
				background-repeat:repeat;
			}
		</style>
	</head>
	<body>
		<div ></div>
	</body>
</html>
Copy after login

How to set image tiling mode in css

2. When the value is "repeat-x", it can be tiled horizontally

repeat-x: Only the horizontal position will repeat the background image

div {
	width: 500px;
	height: 500px;
	border: 2px solid red;
	background-image: url(img/nz.png);
	background-repeat:repeat-x;
}
Copy after login

How to set image tiling mode in css

3. When the value is "repeat-y", it can be tiled vertically

repeat-y: Only the vertical position will repeat the background image

div {
	width: 500px;
	height: 500px;
	border: 2px solid red;
	background-image: url(img/nz.png);
	background-repeat:repeat-y;
}
Copy after login

How to set image tiling mode in css

4. When the value is "no-repeat", it will not be tiled

no-repeat: the background image will only be displayed once

div {
	width: 500px;
	height: 500px;
	border: 2px solid red;
	background-image: url(img/nz.png);
	background-repeat:no-repeat;
}
Copy after login

How to set image tiling mode in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to set image tiling mode 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