当前位置: 首页 > news >正文

JavaWeb03——基础标签及样式(表单)(黑马视频笔记)

1.表单标签 及 表单属性

·表单标签是 :<form>
·表单属性有:action 和 method;
   ·action属性:规定向何处发送表单数据。
 ·method属性:规定用什么方法发送数据。(get和post)
 get:在发送的url后面拼接表单数据,明文显示表单数据的内容,url的长度有限制。
 post:在消息体/请求体中传递,参数大小无限制。

2.表单项 及 属性

表单标签中常包括三种表单项标签:input、select、textarea

        ·input:定义表单项,通过type属性控制输入

             type属性的值有:

                   ① text:默认值,定义单行的输入字段
② password:定义密码字段
③ radio:单选按钮,name属性相同表示在一个备选圈中,value属性不同,表示各自的选项;如果最外层嵌套label标签,这样不用精准点击方格,点击文字部分也可选中
④ checkbox:复选


⑤ file:文件上传
⑥ data/time/datatime-local:定义日期、时间、日期和时间
⑦ number:数字输入框
⑧ email:邮件输入框
⑨ hidden:隐藏域
⑩ submit/reset/button:提交、重置、可点击按钮,value属性的值会展示在按钮上

-------------------------------------------------------------------------------------------------------------------------

        ·select:下拉列表,标签 option 定义列表项

                形式写法:

-------------------------------------------------------------------------------------------------------------------------

        ·textarea:定义文本域

                常见属性的值有:cols和row

                        ① cols:一行最多有几个字符
② rows:默认可以写几行

3.表单效果展示:

<table action=""  methods="get"><h1 style="text-align: center;">基础信息表</h1>姓名:<input type="text" name="name">   <br>  密码:<input type="password" name="password">   <br>    性别:<input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女   <br>爱好: <label><input type="checkbox" name="love" value="1"> 唱歌</label> <label><input type="checkbox" name="love" value="2"> 跳舞</label> <label><input type="checkbox" name="love" value="3"> 绘画</label> <br>上传简历pdf:<input type="file"> <br>选择日期 和 时间:<input type="datetime-local"><br>年龄:<input type="number"><br>邮件:<input type="email"><br>学历:<select name="degree"><option value="1">-----下拉选择学历-----</option><option value="2">高中</option><option value="3">本科</option><option value="4">研究生</option></select><br>其他留言:<textarea cols="30" rows="6"></textarea><br><br><input type="button" name="button" value="按钮">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="reset" name="reset" value="重置">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="submit" name="submit" value="提交"></table>

整个代码:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>表单</title><style>span{margin-left: 60px;color: darkblue;}.div1{width: 380px;height: 600px;background-color:lightgoldenrodyellow;margin-left: 100px;padding: 30px ;line-height: 40px;}div{margin-left: 70px;}</style></head><body><h2>1.表单标签 及 表单属性</h2><p>·表单标签是 :<b>form</b><br>·表单属性有:action 和 method;<br>&nbsp;&nbsp;&nbsp;<b>·action属性:</b>规定向何处发送表单数据。<br>&nbsp;&nbsp;&nbsp;<b>·method属性:</b>规定用什么方法发送数据。(get和post)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;get:在发送的url后面拼接表单数据,明文显示表单数据的内容,url的长度有限制。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;post:在消息体/请求体中传递,参数大小无限制。</p><h2>2.表单项 及 属性</h2><p>表单标签中常包括三种表单项标签:<b>input、select、textarea </b> </p><p style="text-indent: 30px;"><b style="color: blue;">·input:</b>定义表单项,通过type属性控制输入</p><span>type属性的值有:</span><div> ① text:默认值,定义单行的输入字段<br>② password:定义密码字段<br>③ radio:单选按钮,name属性相同表示在一个备选圈中,value属性不同,表示各自的选项;如果最外层嵌套label标签,这样不用精准点击方格,点击文字部分也可选中<br>④ checkbox:复选<br>⑤ file:文件上传<br>⑥ data/time/datatime-local:定义日期、时间、日期和时间<br>⑦ number:数字输入框<br>⑧ email:邮件输入框<br>⑨ hidden:隐藏域<br>⑩ submit/reset/button:提交、重置、可点击按钮,value属性的值会展示在按钮上</div><p style="text-indent: 30px;"><b style="color: blue;">·select:</b>下拉列表,标签 <b>option</b> 定义列表项</p><span>形式写法:</span><br><div> <img src="select.png" width="400px"> </div><p style="text-indent: 30px;"><b style="color: blue;">·textarea:</b>定义文本域</p><span>常见属性的值有:<b>cols和row</b></span><div>① cols:一行最多有几个字符<br>② rows:默认可以写几行</div><h2>3.效果展示:</h2><div class="div1"><table action=""  methods="get"><h1 style="text-align: center;">基础信息表</h1>姓名:<input type="text" name="name">   <br>  密码:<input type="password" name="password">   <br>    性别:<input type="radio" name="sex" value="男">男 <input type="radio" name="sex" value="女">女   <br>爱好: <label><input type="checkbox" name="love" value="1"> 唱歌</label> <label><input type="checkbox" name="love" value="2"> 跳舞</label> <label><input type="checkbox" name="love" value="3"> 绘画</label> <br>上传简历pdf:<input type="file"> <br>选择日期 和 时间:<input type="datetime-local"><br>年龄:<input type="number"><br>邮件:<input type="email"><br>学历:<select name="degree"><option value="1">-----下拉选择学历-----</option><option value="2">高中</option><option value="3">本科</option><option value="4">研究生</option></select><br>其他留言:<textarea cols="30" rows="6"></textarea><br><br><input type="button" name="button" value="按钮">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="reset" name="reset" value="重置">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<input type="submit" name="submit" value="提交"></table></div></body>
</html>

http://www.lryc.cn/news/613122.html

相关文章:

  • 【运维进阶】NFS 服务器
  • 智慧园区系统:打造未来城市生活新体验
  • 第一性原理科学计算服务器如何选择配置-内存选择篇
  • 软考中级【网络工程师】第6版教材 第2章 数据通信基础(下)
  • Windows下Rust编码实现MP4点播服务器
  • 【算法训练营Day22】回溯算法part4
  • Pytest项目_day07(pytest)
  • npm 与 npx 区别详解。以及mcp中npx加载原理。
  • 《深入理解Java字符串:从基础到高级特性》
  • 贪心+矩阵算法
  • 与页面共舞 —— Content Scripts 的魔法
  • 面向对象之类、继承和多态
  • leafletMap封装使用
  • 动手学深度学习13.11. 全卷积网络 -笔记练习(PyTorch)
  • Linux 中断系统全览解析:从硬件到软件的全路线理解
  • 外部排序总结(考研向)
  • MongoDB数据存储界的瑞士军刀:cpolar内网穿透实验室第513号挑战
  • 数据结构:双向链表(Doubly Linked List)
  • 生成对抗网络(GAN)实战 - 创建逼真人脸图像
  • 电路相量法
  • (易视宝)易视TV is-E4-G-全志A20芯片-安卓4-烧写卡刷工具及教程
  • C++的“模板”
  • day069-Jenkins基础使用与参数化构建
  • golang的面向对象编程,struct的使用
  • 急危重症专科智能体”构建新一代急诊、手术与重症中心的AI医疗方向探析
  • 【深度学习机器学习】构建情绪对话模型:从数据到部署的完整实践
  • 小鸡模拟器安卓版:经典街机游戏的移动体验
  • Elcomsoft Wireless Security Auditor 安装教程-安全检测工具使用指南
  • 数据结构----栈和队列认识
  • 深度学习-卷积神经网络CNN-1×1卷积层