自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

HTML 5深入淺出教學(xué)篇之五

開(kāi)發(fā) 前端
本文講到的是HTML 5元素的通用屬性accesskey, style, class, title, tabindex, id, dir, spellcheck, hidden, contenteditable, contextmenu, draggable, dropzone的使用

介紹

HTML 5: 元素的通用屬性

元素的通用屬性 - accesskey, style, class, title, tabindex, id, dir, spellcheck, hidden, contenteditable, contextmenu, draggable, dropzone

示例

1、accesskey - 用于定義快捷鍵element/_globalAttributes/accesskey.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>accesskey</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         accesskey - 用于定義快捷鍵??旖萱I為:alt + accesskey,參考第一個(gè)示例  
  9.           第二個(gè)示例描述為:有全鍵盤(pán)的設(shè)備快捷鍵為:ctrl + alt + q(目前 IE 為:ctrl + shift + q),僅有小鍵盤(pán)的設(shè)備快捷鍵為:“數(shù)字 0 鍵”  
  10.     --> 
  11.     <a accesskey="w" href="http://webabcd.cnblogs.com/">webabcd blog</a> 
  12.     <a accesskey="q 0" href="http://webabcd.cnblogs.com/">webabcd blog</a> 
  13. </body> 
  14. </html> 

2、style - 用于定義樣式element/_globalAttributes/style.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>style</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         style - 用于定義樣式  
  9.     --> 
  10.     <span style="font-size:36px; color:Blue">webabcd</span> 
  11. </body> 
  12. </html> 

3、class - 指定需要應(yīng)用的 css 類(lèi)選擇器element/_globalAttributes/class.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>class</title> 
  5.     <style> 
  6.         .myClass { font-size:36px; }  
  7.         .myClass2 { color:Blue; }  
  8.     </style> 
  9. </head> 
  10. <body> 
  11.     <!--  
  12.         class - 指定需要應(yīng)用的 css 類(lèi)選擇器  
  13.     --> 
  14.     <span class="myClass myClass2">webabcd</span> 
  15. </body> 
  16. </html> 

4、title - 用于描述元素信息,相當(dāng)于 ToolTipelement/_globalAttributes/title.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>title</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         title - 用于描述元素信息,相當(dāng)于 ToolTip  
  9.     --> 
  10.     <a title="webabcd" href="http://webabcd.cnblogs.com/">webabcd blog</a> 
  11.     <img src="http://pic.cnblogs.com/avatar/a14540.jpg?id=24173245" alt="頭像" title="webabcd" /> 
  12. </body> 
  13. </html> 

#p#

5、tabindex - 用于定義 TAB 鍵的導(dǎo)航順序(整型值)element/_globalAttributes/tabindex.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>tabindex</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         tabindex - 用于定義 TAB 鍵的導(dǎo)航順序(整型值)  
  9.           按從小到大的順序?qū)Ш剑? 除外,0 會(huì)被最后導(dǎo)航到)  
  10.           負(fù)數(shù)則不會(huì)被導(dǎo)航到  
  11.     --> 
  12.     <input type="text" tabindex="-1" />   
  13.     <input type="text" tabindex="-2" /> 
  14.     <input type="text" tabindex="0" /> 
  15.     <input type="text" tabindex="3" /> 
  16.     <input type="text" tabindex="1" /> 
  17.     <input type="text" tabindex="4" /> 
  18.     <input type="text" tabindex="2" /> 
  19. </body> 
  20. </html> 

6、id - 用于定義元素的唯一標(biāo)識(shí),主要給 DOM 用element/_globalAttributes/id.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>id</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         id - 用于定義元素的唯一標(biāo)識(shí),主要給 DOM 用  
  9.     --> 
  10.     <a id="myId" href="http://webabcd.cnblogs.com/">webabcd blog</a> 
  11.  
  12.     <script type="text/javascript"> 
  13.         alert(document.getElementById('myId').innerHTML);  
  14.     </script> 
  15. </body> 
  16. </html> 

7、dir - 文本排列方向,可能的值有:auto|ltr|rtl(dir 是 direction 的縮寫(xiě))element/_globalAttributes/dir.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>dir</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         bdo - 定義文本排列的方向(bdo 是 bi-directional override 的縮寫(xiě))  
  9.           dir - 文本排列方向,可能的值有:auto|ltr|rtl(dir 是 direction 的縮寫(xiě))  
  10.     --> 
  11.     <bdo dir="rtl">123</bdo> 
  12. </body> 
  13. </html> 

8、spellcheck - 是否使用瀏覽器的拼寫(xiě)檢查功能對(duì)元素內(nèi)的內(nèi)容做拼寫(xiě)檢查element/_globalAttributes/spellcheck.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>spellcheck</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         spellcheck - 是否使用瀏覽器的拼寫(xiě)檢查功能對(duì)元素內(nèi)的內(nèi)容做拼寫(xiě)檢查(支持如下元素:textarea; 類(lèi)型為 text 的 input; contenteditable 為 true 的元素)  
  9.           可能的值有:"", "true", "false"  
  10.     --> 
  11.     <textarea rows="10" cols="20" spellcheck="true"> 
  12. i am jack, i am webabcd, haha, good, hehe  
  13.     </textarea> 
  14. </body> 
  15. </html> 

#p#

9、hidden - 用于隱藏元素(不占位)element/_globalAttributes/hidden.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>hidden</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         hidden - 用于隱藏元素(不占位)  
  9.     --> 
  10.     <input type="text" hidden />     
  11.     <input type="text" /> 
  12.     <input type="text" hidden /> 
  13. </body> 
  14. </html> 

10、contenteditable - 用于定義內(nèi)容是否可編輯element/_globalAttributes/contenteditable.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>contenteditable</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         contenteditable - 用于定義內(nèi)容是否可編輯  
  9.           可能的值有:"", "true", "false"  
  10.     --> 
  11.     <p contenteditable>我是可以編輯的,試試看</p> 
  12. </body> 
  13. </html> 

11、contextmenu - 指定上下文菜單的數(shù)據(jù)源element/_globalAttributes/contextmenu.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>contextmenu</title> 
  5. </head> 
  6. <body> 
  7.     <!--  
  8.         contextmenu - 指定上下文菜單的數(shù)據(jù)源  
  9.  
  10.         menu - 定義菜單(目前僅有 FireFox 實(shí)現(xiàn)了 context 菜單)  
  11.           type - 菜單的類(lèi)型,有兩種類(lèi)型:context(右鍵菜單) 和 toolbar(工具欄菜單)  
  12.           label - 菜單的名稱,顯示用  
  13.           menuitem - 定義菜單項(xiàng)(菜單的子集)  
  14.             label - 菜單項(xiàng)的名稱,顯示用  
  15.             icon - 菜單項(xiàng)的圖標(biāo)  
  16.     --> 
  17.     <section contextmenu="myContextMenu"> 
  18.         <img src="http://www.w3.org/html/logo/downloads/HTML5_Logo_512.png" alt="" /> 
  19.         <menu type="context" id="myContextMenu"> 
  20.             <menuitem label="menuitem1" onclick="alert('menuitem1')" icon="http://pic.cnblogs.com/avatar/a14540.jpg?id=24173245"></menuitem> 
  21.             <menuitem label="menuitem2" onclick="alert('menuitem2')"></menuitem> 
  22.             <menu label="menuitem3" icon="http://pic.cnblogs.com/avatar/a14540.jpg?id=24173245"> 
  23.                 <menuitem label="menuitem31" onclick="alert('menuitem31')" icon="http://pic.cnblogs.com/avatar/a14540.jpg?id=24173245"></menuitem> 
  24.                 <menuitem label="menuitem32" onclick="alert('menuitem32')" icon="http://pic.cnblogs.com/avatar/a14540.jpg?id=24173245"></menuitem> 
  25.             </menu> 
  26.         </menu> 
  27.     </section> 
  28.     <!-- 工具欄式的菜單,目前還沒(méi)有瀏覽器實(shí)現(xiàn)此標(biāo)準(zhǔn) --> 
  29.     <section contextmenu="myToolbarMenu"> 
  30.         <menu type="toolbar"> 
  31.             <li> 
  32.                 <menu label="File"> 
  33.                     <button type="button" onclick="fnew()"> 
  34.                         New...</button> 
  35.                     <button type="button" onclick="fopen()"> 
  36.                         Open...</button> 
  37.                     <button type="button" onclick="fsave()"> 
  38.                         Save</button> 
  39.                     <button type="button" onclick="fsaveas()"> 
  40.                         Save as...</button> 
  41.                 </menu> 
  42.             </li> 
  43.             <li> 
  44.                 <menu label="Edit"> 
  45.                     <button type="button" onclick="ecopy()"> 
  46.                         Copy</button> 
  47.                     <button type="button" onclick="ecut()"> 
  48.                         Cut</button> 
  49.                     <button type="button" onclick="epaste()"> 
  50.                         Paste</button> 
  51.                 </menu> 
  52.             </li> 
  53.             <li> 
  54.                 <menu label="Help"> 
  55.                     <li><a href="#">Help</a></li> 
  56.                     <li><a href="#">About</a></li> 
  57.                 </menu> 
  58.             </li> 
  59.         </menu> 
  60.     </section> 
  61. </body> 
  62. </html> 

12、draggable - 元素是否可拖拽;dropzone - 拖放的目標(biāo)元素(可承載被拖拽元素的元素)element/_globalAttributes/draggable_dropzone.html

  1. <!doctype html> 
  2. <html> 
  3. <head> 
  4.     <title>draggable dropzone</title> 
  5. </head> 
  6. <body> 
  7.     <span>關(guān)于 draggable 和 dropzone 的詳細(xì)說(shuō)明,參見(jiàn) /other/drag_drop</span> 
  8. </body> 
  9. </html> 

[源碼下載]

原文鏈接:http://www.cnblogs.com/webabcd/archive/2012/02/02/2335318.html

責(zé)任編輯:張偉 來(lái)源: webabcd的博客
相關(guān)推薦

2012-05-31 09:35:43

HTML5

2012-05-30 15:17:54

HTML5

2012-05-30 14:51:09

HTML5

2012-05-31 09:19:22

HTML5

2012-05-31 10:57:06

HTML5

2012-05-30 13:26:12

HTML5

2012-05-31 09:54:13

HTML5

2012-05-30 11:11:42

HTML5

2012-05-30 13:17:46

HTML5

2012-05-30 10:52:09

HTML5

2009-11-17 17:31:58

Oracle COMM

2022-02-25 08:54:50

setState異步React

2009-11-18 13:30:37

Oracle Sequ

2011-07-04 10:39:57

Web

2013-11-14 15:53:53

AndroidAudioAudioFlinge

2021-03-16 08:54:35

AQSAbstractQueJava

2017-06-05 14:50:33

大數(shù)據(jù)數(shù)據(jù)庫(kù)壓縮

2017-06-06 15:34:41

物聯(lián)網(wǎng)數(shù)據(jù)庫(kù)壓縮

2022-09-26 09:01:15

語(yǔ)言數(shù)據(jù)JavaScript

2012-02-07 15:29:17

Android核心組件Service
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)