คุณสมบัติการมองเห็น CSS
ตัวอย่าง
ทำให้องค์ประกอบ <h2> มองเห็นได้และซ่อนไว้:
h2.a {
visibility: visible;
}
h2.b {
visibility: hidden;
}
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติvisibility
ระบุว่าองค์ประกอบสามารถมองเห็นได้หรือไม่
เคล็ดลับ:องค์ประกอบที่ซ่อนอยู่ใช้พื้นที่บนหน้า ใช้ คุณสมบัติ displayเพื่อซ่อนและลบองค์ประกอบออกจากเค้าโครงเอกสาร!
ค่าเริ่มต้น: | มองเห็นได้ |
---|---|
รับการถ่ายทอด: | ใช่ |
เคลื่อนไหวได้: | ใช่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS2 |
ไวยากรณ์ JavaScript: | วัตถุ .style.visibility="hidden" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
visibility | 1.0 | 4.0 | 1.0 | 1.0 | 4.0 |
ไวยากรณ์ CSS
visibility: visible|hidden|collapse|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
visible | Default value. The element is visible | |
hidden | The element is hidden (but still takes up space) | |
collapse | Only for table rows (<tr>), row groups (<tbody>), columns (<col>),
column groups (<colgroup>). This value removes a row or column,
but it does not affect the table layout. The space taken up by the row or column
will be available for other content. If collapse is used on other elements, it renders as "hidden" |
|
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ตัวอย่างนี้สาธิตวิธีทำให้องค์ประกอบตารางยุบ:
tr.collapse {
visibility: collapse;
}
หน้าที่เกี่ยวข้อง
กวดวิชา CSS: การแสดงผล CSS และการมองเห็น
การอ้างอิง HTML DOM: คุณสมบัติการมองเห็น