กล่องสไตล์คุณสมบัติการ ปรับขนาด
ตัวอย่าง
เปลี่ยนคุณสมบัติ boxSizing:
document.getElementById("myDIV").style.boxSizing = "border-box";
ความหมายและการใช้งาน
คุณสมบัติ boxSizing ช่วยให้คุณสามารถกำหนดองค์ประกอบบางอย่างเพื่อให้พอดีกับพื้นที่ในลักษณะที่แน่นอน
ตัวอย่างเช่น หากคุณต้องการให้กล่องที่มีเส้นขอบสองกล่องอยู่เคียงข้างกัน สามารถทำได้โดยการตั้งค่า boxSizing เป็น "border-box" สิ่งนี้บังคับให้เบราว์เซอร์แสดงกล่องด้วยความกว้างและความสูงที่ระบุ และวางเส้นขอบและช่องว่างภายในกล่อง
รองรับเบราว์เซอร์
Property | |||||
---|---|---|---|---|---|
boxSizing | Yes | Yes | Yes | Yes | Yes |
ไวยากรณ์
ส่งคืนคุณสมบัติการปรับขนาดกล่อง:
object.style.boxSizing
ตั้งค่า boxSizing คุณสมบัติ:
object.style.boxSizing = "content-box|border-box|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
content-box | Default value. This is the behavior of width and height as specified by CSS2.1. The specified width and height (and min/max properties) apply to the width and height respectively of the content box of the element. The padding and border of the element are laid out and drawn outside the specified width and height |
border-box | The specified width and height (and min/max properties) on this element determine the border box of the element. That is, any padding or border specified on the element is laid out and drawn inside this specified width and height. The content width and height are calculated by subtracting the border and padding widths of the respective sides from the specified 'width' and 'height' properties |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | กล่องเนื้อหา |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงคุณสมบัติการปรับขนาดกล่องขององค์ประกอบ |
เวอร์ชัน CSS | CSS3 |
หน้าที่เกี่ยวข้อง
การอ้างอิง CSS: คุณสมบัติการปรับขนาดกล่อง
❮ สไตล์วัตถุ