HTML DOM display屬性語法實例解析
作者:css
大家對CSS display屬性的用法應該比較熟悉,這個屬性用于定義建立布局時元素生成的顯示框類型,那么HTML DOM display 屬性有何用途呢,請看本文詳細介紹。
這里向大家描述一下HTML DOM display屬性的定義和用法,HTML DOM display屬性主要用來設置元素如何顯示,比如當此屬性值為none時,表示此元素不會被顯示,而block則表示此元素將顯示為塊級元素,此元素前后會帶有換行符。
HTML DOM display屬性定義和用法
此屬性主要用來設置元素如何顯示。
語法:
Object.style.display=value
可能的值
HTML DOM display屬性實例
本例設置不顯示元素:
- <html>
- <head>
- <script type="text/javascript">
- function removeElement()
- {
- document.getElementById("p1").style.display="none";
- }
- </script>
- </head>
- <body>
- <h1>Hello</h1>
- <p id="p1">This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.
- This is some text. This is some text. This is some text.</p>
- <input type="button" onclick="removeElement()"
- value="Do not display paragraph" />
- </body>
- </html>
【編輯推薦】
- CSS display屬性基本特性和語法
- 探究CSS hack使用原理 規(guī)則及弊端
- 深入探究DIV CSS布局中position屬性用法
- CSS屬性display:inline-block使用揭秘
- CSS hack:實現(xiàn)IE6、IE7、Firefox兼容
責任編輯:佚名
來源:
w3school.com.cn