คุณสมบัติ background-position
เพื่อกำหนดตำแหน่งภาพพื้นหลัง ให้ใช้คุณสมบัติ background-position
ตัวอย่าง
ตัวอย่างนี้ตั้งตำแหน่งภาพพื้นหลังห่างจากด้านซ้าย 80 พิกเซล:
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-position: 80px;
}
</style>
</head>
<body>
<p>Tutorials point</p>
</body>
</html>
รูปแบบค่าที่ใช้ได้:
- คีย์เวิร์ด: left, center, right, top, bottom
- เปอร์เซ็นต์: 50% 50% = กึ่งกลาง
- หน่วยความยาว: 80px 20px (x, y)
- ผสมผสาน: right 20px bottom 10px
ค่าเดียว = ตำแหน่งแนวนอน (แนวตั้ง = center อัตโนมัติ)