如何像专业人士一样制作 HTML 表单 这是 html5 中所有输入类型的列表!

2025-05-25

如何像专业人士一样制作 HTML 表单

这是html5 中所有输入类型的列表!

Hello World!今天我们讨论的是 HTML 表单,它主要面向初学者,但任何人都有时需要复习一下。
所以,虽然我相信你已经了解了这一点……

这是html5 中所有输入类型的列表!

另请阅读:

并记住喜欢❤️❤️


<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text">
<input type="time">
<input type="url">
<input type="week">
Enter fullscreen mode Exit fullscreen mode

来源:w3schools

替代文本


您还可以拥有:

  • 标签 --><label for="username">Click me to focus on input</label>
  • 禁用输入 --><input type="text" placeholder="This is a text input Disabled" disabled>
  • 多个答案输入(可能带有禁用选项)-->
<select name="Select" id="Select">
      <option value="Default">Default field</option>
      <option value="1">Field 1</option>
      <option value="2" disabled>Fiel 2</option>
      <option value="3">Field 3</option>
      <option value="4" disabled>Fiel 4</option>
    </select>
Enter fullscreen mode Exit fullscreen mode
  • 占位符 --><input type="text" placeholder="I am the placeholder"> 替代文本
  • 一个很酷的用户友好形式--> ...

您可以在这里进行实时预览(以防您错过某些内容):
点击我


现在是时候添加一些风格了!

首先是基础知识

:徘徊

  input:hover {
  background-color: whitesmoke;
  margin-bottom: 1%;
  border-width: 3px;
}
Enter fullscreen mode Exit fullscreen mode

:重点

  input:focus {
  background-color: yellow;
  color: black;
}
Enter fullscreen mode Exit fullscreen mode

替代文本

经过长时间的搜索:这里有一些时尚的形式:

简洁:
联系我们表单 (CodePen)
安静:
登录表单
奢华:
注册表单
互动:
登录表单
多彩:
联系我们表单

现在列出 41 个(是的,41 个)响应式表单:
替代文本

请按赞按钮♡


现在,如果您上周开始进行 Web 开发,我很抱歉,但您还需要一点 JS:

防止违约不会伤害任何人

form.addEventListener("submit", function (e) {
    e.preventDefault();
});
Enter fullscreen mode Exit fullscreen mode

从表单中检索信息:

form.addEventListener("submit", function (e) {
    InputValue = document.getElementById("InputId").value;
});
Enter fullscreen mode Exit fullscreen mode

检查电子邮件是否有效:

检查密码是否有效:

Codepen 示例:


希望这能有所帮助,感谢您的阅读!

查看这篇文章:终极速查表汇编(100+)-🎁/开发路线图🚀


订阅我的时事通讯!

为您带来冗长而有趣的每周回顾
我的文章的免费 PDF 版本
高度可定制的收件箱
那是 --> 免费 <-- 而且您可以帮助我!

文章来源:https://dev.to/lorenzoblog/the-fabulous-list-of-all-form-input-types-48ig
PREV
使用 github.dev 可以做的有趣的事情😎
NEXT
代码修订实践博阿斯