02.表单补充.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. form{
  10. margin-top: 100px;
  11. margin-left: 300px;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <form action="target.html">
  17. <!-- 文本框中的value值为默认值,如果不输入其他内容,提交的就是默认值的内容 -->
  18. <input type="text" name="username" value="hello">
  19. <br><br>
  20. <!--
  21. 在文本框中输入内容时,会默认显示我们已经输入过的内容列表(自动补全功能)
  22. autocomplete="off" 可以关闭自动补齐功能
  23. 但是它只能影响自己所在的输入框,对其他的输入框没有效果
  24. 需要对其他的输入框进行单独的设置
  25. 如果要把全部输入框的自动补全功能都关闭,可以在form标签中添加
  26. -->
  27. <input type="text" name="username" autocomplete="off">
  28. <br><br>
  29. <!--
  30. readonly 将表单项设置为只读,数据会提交
  31. 本例中将不能对默认文字“hello”进行修改
  32. -->
  33. <input type="text" name="username" value="hello" readonly>
  34. <br><br>
  35. <!--
  36. disabled 将表单项设置为禁用,数据不会提交
  37. 有点类似于readonly,只是输入框整个都会变成灰色的,readonly则不会
  38. -->
  39. <input type="text" name="username" value="hello" disabled>
  40. <br><br>
  41. <!--
  42. autofocus 设置表单项自动获取焦点
  43. -->
  44. <input type="text" name="username" autofocus>
  45. <br><br>
  46. <!--
  47. input的type类型为color时,会出现一个颜色选择按钮,可以选择颜色
  48. 但实际开发中使用较少,主要是兼容性不太好
  49. -->
  50. <input type="color">
  51. <br><br>
  52. <!--
  53. input的type类型为email时,其显示效果和text没有区别,但是当输入内容后点击提交时,
  54. 它会检查输入的内容是否符合邮件的格式,如果不符合,会弹出提示信息
  55. 但是在IE中的提示信息不一样,所以也很少用
  56. color和email在PC端用的比较少,但是在移动端开发时用得比较多
  57. -->
  58. <input type="email">
  59. <br><br>
  60. <input type="submit">
  61. <input type="reset">
  62. <!-- reset可以将用户输入的值重新设置为默认值 -->
  63. <input type="button" value="按钮">
  64. <!-- 普通的按钮,这样设置的按钮点了以后没有任何反应,其功能需要配合js完成(用处广泛) -->
  65. <br><br>
  66. <button type="submit">提交</button>
  67. <button type="reset">重置</button>
  68. <button type="button">按钮</button>
  69. <!-- 相比之下,button会使用的更多一些 -->
  70. </form>
  71. </body>
  72. </html>