Computer >> Máy Tính >  >> Lập trình >> CSS

Lặp lại nền trong CSS

Lặp lại nền trong CSS được sử dụng để đặt cách lặp lại hình nền trên trang web. Đối với điều này, hãy sử dụng thuộc tính background-repeat. Sau đây có thể là các giá trị thuộc tính -

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

Ví dụ

Bây giờ chúng ta hãy xem một ví dụ -

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.tutorialspoint.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>

Đầu ra

Lặp lại nền trong CSS

Ví dụ

Bây giờ chúng ta hãy xem một ví dụ khác -

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.tutorialspoint.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>

Đầu ra

Lặp lại nền trong CSS