HTML基础-表单标签,button按钮,select下拉菜单

HTML基础-表单标签

目标和学习路径

1.表单标签

1.1 input系列标签的基本介绍

1.2 input系列标签-文本框

(拓展)value属性和name属性作用介

1.3 input系列标签-密码框

1.4 input系列标签-单选框

1.5 input系列标签-复选框

1.6 input系列标签-文件选择

2.button按钮标签

1.7 input系列标签-按钮

测试代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
         <!-- 写什么就显示什么 -->
         文本框: <input type="text" placeholder="提示用户该输入啥?">
         <br>
         <br>
         <!-- 书写的内容都会变成点点显示 -->
         密码框: <input type="password" placeholder="请输入密码">

         <br>
         <br>
         单选框: <input type="radio">
         <br>
         <!-- name:有相同值的为一组,一组中只能一个被选中 -->
         <br>
         单选框: <input type="radio" name="key"><input type="radio" name="key"><input type="radio" name="key">
         <br>
         <!-- checked:默认选中 -->
         <br>
         单选框: <input type="radio" checked>
         <br>
         <br>
         多选框: <input type="checkbox"><input type="checkbox"><input type="checkbox">
         <br>
         <br>

         上传文件: <input type="file">

         <!-- multiple 多文件选择 -->
         上传文件: <input type="file" multiple>
    
         <button>我是按钮</button>
         <button type="submit">提交按钮</button>
         <button type="reset">重置按钮</button>
         <button type="button">普通按钮, 没有任何功能</button>
</body>
</html>
测试结果:

关于input的标签总结:

3. select下拉菜单

3.1 select下拉菜单标签

4.1 textarea文本域标签

测试代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>select下拉菜单</h2>
    <select name="所有城市" id="allcity">
        <option>保山</option>
        <option>合肥</option>
        <option>鹤庆</option>
        <!-- selectde默认就是选中的 -->
        <option selected>安庆</option>
    </select>

    <br>
    <!-- 当输入很多的内容时候就可以用这个 -->
    详细描述:<textarea cols="6" rows="3"></textarea>

    <br>
    <!-- 可能小框子太小了,不好选,可以加上label标签,选择字也可以选中 -->
    性别: 
    <input type="radio" name="sex" id="nan">
    <label for="nan">男</label>
    <label><input type="radio" name="sex"> 女</label>
</body>
</html>
测试结果:

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个包含选框,复选框,输入框,下菜单和提交按钮的 Bootshape 的示例代码: ```html <form> <div class="form-group"> <label for="nameInput">Name</label> <input type="text" class="form-control" id="nameInput" placeholder="Enter your name"> </div> <div class="form-group"> <label for="emailInput">Email address</label> <input type="email" class="form-control" id="emailInput" placeholder="Enter your email address"> </div> <div class="form-group"> <label for="genderInput">Gender</label> <div class="form-check"> <input class="form-check-input" type="radio" name="genderInput" id="maleRadio" value="male"> <label class="form-check-label" for="maleRadio"> Male </label> </div> <div class="form-check"> <input class="form-check-input" type="radio" name="genderInput" id="femaleRadio" value="female"> <label class="form-check-label" for="femaleRadio"> Female </label> </div> </div> <div class="form-group"> <label for="interestsInput">Interests</label> <div class="form-check"> <input class="form-check-input" type="checkbox" value="music" id="musicCheckbox"> <label class="form-check-label" for="musicCheckbox"> Music </label> </div> <div class="form-check"> <input class="form-check-input" type="checkbox" value="sports" id="sportsCheckbox"> <label class="form-check-label" for="sportsCheckbox"> Sports </label> </div> <div class="form-check"> <input class="form-check-input" type="checkbox" value="movies" id="moviesCheckbox"> <label class="form-check-label" for="moviesCheckbox"> Movies </label> </div> </div> <div class="form-group"> <label for="citySelect">City</label> <select class="form-control" id="citySelect"> <option>New York</option> <option>Los Angeles</option> <option>Chicago</option> <option>Houston</option> <option>Philadelphia</option> </select> </div> <button type="submit" class="btn btn-primary">Submit</button> </form> ``` 这个包括五个输入字段:姓名,电子邮件地址,性别(选框),兴趣爱好(复选框),城市(下菜单)。每个输入字段都有一个相应的标签和占位符文本。中还有一个提交按钮。这个的样式使用了 Bootstrap 的默认样式。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值