Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

การตั้งค่าตำแหน่งพื้นหลังโดยใช้ CSS


ตำแหน่งพื้นหลังคือการกำหนดตำแหน่งเริ่มต้นของภาพพื้นหลัง สำหรับสิ่งนี้ ให้ใช้คุณสมบัติตำแหน่งพื้นหลัง

ตัวอย่าง

เรามาดูตัวอย่างกัน −

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.tutorialspoint.com/images/Swift.png");
   background-repeat: no-repeat;
   background-attachment: fixed;
   color: blue;
   background-position: left center;
}
.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>

ผลลัพธ์

การตั้งค่าตำแหน่งพื้นหลังโดยใช้ CSS

ตัวอย่าง

เรามาดูตัวอย่างอื่นกัน −

<!DOCTYPE html>
<html>
<head>
<style>
body {
   background-image: url("https://www.tutorialspoint.com/images/Swift.png");
   background-repeat: no-repeat;
   background-attachment: fixed;
   color: blue;
   background-position: 50% 50%;
}
</style>
</head>
<body>
<h1>Details</h1>
<p>Examination Center near ABC College.</p>
<p>Exam begins at 9AM.</p>
</body>
</html>

ผลลัพธ์

การตั้งค่าตำแหน่งพื้นหลังโดยใช้ CSS