XiZev / blog

record my learning of font-end
0 stars 0 forks source link

表单Form #22

Open XiZev opened 1 month ago

XiZev commented 1 month ago

form标签相对于div标签的区别:enter会触发submit

<form class="container">
   ...
</form
XiZev commented 1 month ago

表单元素一般使用div嵌套,方便使用css

<div class="form-item">
  <input type="text" placeholder="请输入11位手机号码" maxlength="11">
</div>
XiZev commented 1 month ago

type="button" 普通按钮,不会触发表单的submit动作

<button type="button">发送验证码</button>

type="submit" 提交按钮,会触发页面刷新

<button type="submit">立即注册</button>

type="reset" 重置按钮,会清空表单

<button type="reset">重置表单</button>

XiZev commented 1 month ago

标签的布尔属性:属性名等于属性值,可直接简写成属性名

<select multiple="multiple"></select>
<select multiple></select>
XiZev commented 1 month ago
<div>
  <!-- 通过设置同一个name实现单选-互斥选中 -->
  <input type="radio" name="sex" id="male">
  <!-- 通过for关联radio的id值,实现点击label选中 -->
  <label for="male">男</label>
  <!-- label标签包裹 所有元素关联一起,可一起点击选中-->
  <label>
    <input type="radio" name="sex">
    <span>女</span>
  </label>
</div>