知識點---

一、在pc端的input是一個大的知識點

 

【1】文本框 

 

<input type="text">

 

【2】 密碼框 

 

<input type="password">

 

【3】提交按鈕

 

<input type="submit" >  

 

【4】重置按鈕 

 

<input type="reset" >

 

【5】單選框 

 

<input type="radio" >

 

【6】復選框 

 

<input type="checkbox" >

 

【7】普通按鈕 

 

<input type="button" >

 

【8】 文件選擇控件 

 

<input type="file" >

 

【9】隱藏框 

 

<input type="hidden" >

 

【10】 圖片按鈕
<input type="image" >

 

補充:

 

placeholder 屬性提供可描述輸入字段預期值的提示信息(hint)。

 

該提示會在輸入字段為空時顯示,並會在字段獲得焦點時消失。

 

placeholder 屬性適用於以下的 <input> 類型:text, search, url, telephone, email 以及 password。
二、<input type="text">標簽與<textarea>的區別

在我們開發時經常需要用到輸入框,通常解決辦法就是<input type="text">和<textarea>,那么這兩個標簽有什么區別呢?

 

1:<input type="text">標簽

  text標簽是單行文本框,不會換行。

  通過size屬性指定顯示字符的長度,注意:當使用css限定了寬高,那么size屬性就不再起作用。

  value屬性指定初始值,Maxlength屬性指定文本框可以輸入的最長長度。

      可以通過width和height設置寬高,但是也不會增加行數,下面是一個例子:

<input type="text" style="width: 200px; height: 100px" value="我是設置過寬高的text">  

  結果:文本依然只有一行,並且居中顯示。

2:<textarea>標簽

  <textarea>是多行文本輸入框,文本區中可容納無限數量的文本,其中的文本的默認字體是等寬字體(通常是 Courier),可以通過 cols 和 rows 屬性來規定 textarea 的尺寸,不過更好的辦法是使用 CSS 的 height 和 width 屬性。下面是一個例子:

<textarea rows="5" cols="5">我是通過cols和rows定的大小,我的cols是20,rows是10</textarea>

  結果:

  

<textarea style="width: 200px; height: 100px">我是通過width和height定的大小,我的width是200px,heigh是100px</textarea>

  結果:

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM