Home  >  Article  >  Web Front-end  >  How to remove duplicate background images in css

How to remove duplicate background images in css

青灯夜游
青灯夜游Original
2021-11-09 17:05:324828browse

In CSS, you can use the background-repeat attribute to clear background image duplication. You only need to set the value of this attribute to "no-repeat" to specify that the background image does not repeat, that is, the background image will only be displayed. Once; syntax "background-repeat:no-repeat;".

How to remove duplicate background images in css

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

When css uses the background-image attribute to set a background image, sometimes due to image size problems, repeated tiling will occur:

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

How to remove duplicate background images in css

So how to clear it What if the background image is repeated so that only one is displayed? This requires the use of the background-repeat attribute.

The background-repeat attribute is used to set whether and how to repeat the background image. When the value is "no-repeat", you can specify that the background image will not repeat, that is, the background image will only be displayed once.

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

How to remove duplicate background images in css

(Learning video sharing: css video tutorial

The above is the detailed content of How to remove duplicate background images 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