สไตล์วัตถุคุณสมบัติ ตำแหน่ง
ตัวอย่าง
ปรับขนาดรูปภาพให้พอดีกับกล่องเนื้อหา และวางตำแหน่งรูปภาพ 5px จากด้านซ้ายและ 10% จากด้านบนในกล่องเนื้อหา:
document.getElementById("myImg").style.objectPosition = "0 10%";
ความหมายและการใช้งาน
คุณสมบัติ objectPosition ใช้เพื่อระบุว่าควรวางตำแหน่ง <img> หรือ <วิดีโอ> ในกล่องเนื้อหาของตัวเองอย่างไร
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
objectPosition | 31.0 | 16.0 | 36.0 | 10.1 | 19.0 |
ไวยากรณ์
ส่งคืนคุณสมบัติ objectPosition:
object.style.objectPosition
ตั้งค่าคุณสมบัติ objectPosition:
object.style.objectPosition = "position|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
position | Specifies the position of the image or video inside its content box. First value controls the x-asis and the second value controls the y-axis. Can be a string (left, center or right), or a number (in px or %). Negative values are allowed |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | 50% 50% |
---|---|
คืนมูลค่า: | สตริงหรือตัวเลข แทนตำแหน่งขององค์ประกอบในกล่องเนื้อหา |
เวอร์ชัน CSS | CSS3 |
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: CSS วัตถุพอดี
การอ้างอิง CSS: คุณสมบัติตำแหน่งวัตถุ
❮ สไตล์วัตถุ