使用 CSS 实现背景重复

cssweb developmentfront end technology更新于 2025/1/19 7:40:17

CSS background-repeat 属性用于定义背景图像如何重复。

语法

CSS background-repeat 属性的语法如下 −

Selector {
   background-repeat: /*value*/
}

示例

以下示例演示了 CSS background-repeat 属性−

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.cainiaomax.com/images/microsoftproject.png");
   background-repeat: repeat;
}
</style>
</head>
<body>
</body>
</html>

输出

这将给出以下输出 −

示例

<!DOCTYPE html>
<html>
<head>
<style>
ul {
   background-image: url("https://www.cainiaomax.com/images/questions-answers.png");
   background-repeat: space repeat;
}
</style>
</head>
<body>
<h2>Tutorials</h2>
<ul>
<li>Java</li>
<li>C#</li>
<li>Etherum</li>
<li>DBMS</li>
<li>OS</li>
</ul>
</body>
</html>

输出

这将给出以下输出 −


相关文章


有用资源