玩轉html5(一)-----盤點html5新增的那些酷酷的input類型和屬性

來源:互聯網
上載者:User

標籤:date   比例   idt   數字   height   版本號碼   one   最大   time   

請珍惜小編勞動成果,該文章為小編原創。轉載請註明出處。


今天正式開始學習html5了。相比html曾經的版本號碼。html5新增了好多功能,屬性,使我們做出來的介面更加的絢麗。並且使用起來超級簡單,這篇文章先來說說html添加的那些input類型和屬性。

這些代碼是在獵豹瀏覽器下實現的。

html5新增的input類型有:email,url,number,range,date pickers,datalist,telephone,search,color

email:提交時會自己主動驗證輸入的內容是否滿足格式

郵箱 :<input type="email" name="user_email"/>


url:提交時會自己主動驗證輸入內容是否為url

url: <input type="url" name="user_url"/>


number:用於輸入數字,當中min為最小值。max為最大值,step為點擊箭頭是數位變化量,value為預設值,min,max,step,value均可不寫

 年齡:<input type="number" name="user_age" min="18" max="120" step="1" value="20"/>


range:用於應該包括一定範圍內數字值的輸入欄位,顯示為滑動條

 比例:<input type="range" name="user_range" min="10" max="100"/></br>

date pickers:有date,month,week,time,datetime,datetime-local這幾種類型。

date--選取年月日,month---選取年月,week---選取年周。time--選取小時和分鐘,datetime--選取年月日時間。datetime-local--選取本地時間

這裡給一個datetime-local的

時間:<input type="datetime-local" name="user_date"/>


datalist:相當於下拉式清單,有自己主動補充功能

 網址: <input type="url" list="url_list" name="link" required />      <!-- 自己主動補充 -->             <datalist id="url_list">               <option label="web1" value="http://www.web1.com.cn" />               <option label="web2" value="http://www.web2.com" />               <option label="web3" value="http://www.web3.com" />             </datalist>


color:顏色選取器

顏色:<input type="color"/>


還有兩個類型是telephone和search。因為我使用時看不出效果來,就不在這裡寫了。大家自己試試。



玩轉html5(一)-----盤點html5新增的那些酷酷的input類型和屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.