CSS 中的背景重复

cssweb developmentfront end technology更新于 2024/12/10 10:20:17

CSS 中的背景重复用于设置背景图像在网页上的重复方式。为此,请使用 background-repeat 属性。以下是属性值 −

background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial|inherit;

示例

现在让我们看一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.cainiaomax.com/images/Swift.png");
   background-repeat: repeat-x;
   background-color: blue;
   color: white;
}
.demo {
   text-decoration: overline underline;
}
</style>
</head>
<body>
<h1>Details</h1>
<p class="demo">Examination Center near ABC College.</p>
<p class="demo2">Exam begins at 9AM.</p>
</body>
</html>

输出

示例

现在让我们看另一个例子 −

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.cainiaomax.com/images/Swift.png");
   background-repeat: repeat-y;
   background-color: orange;
   color: white;
}
.demo {
   text-decoration: overline underline;
}
</style>
</head>
<body>
<h1>Details</h1>
<p class="demo">Examination Center near ABC College.</p>
<p class="demo2">Exam begins at 9AM.</p>
</body>
</html>

输出


相关文章


有用资源