博客列表 >表单知识和内联框架

表单知识和内联框架

李玉峰
李玉峰原创
2022年03月21日 19:00:19525浏览

一、表单知识

  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>表单知识</title>
  8. </head>
  9. <body>
  10. <!-- method提交类型:默认get提交以?k=y&k=y查询字符串提交到URL -->
  11. <!-- post提交更安全,在浏览器 网络-》载荷 中可查看 -->
  12. <form action="login.php" method="post">
  13. <div>
  14. <!-- type:类型、name:传值变量、value:值 -->
  15. <label for="username">用户名:</label>
  16. <!-- label中的for和input中的id绑定,值必须一样:label.for = input.id,点击“用户名”会将鼠标焦点落入输入框 -->
  17. <!-- autofocus 打开页面自动获取鼠标焦点落入输入框,默认true,值是它本身autofocus -->
  18. <!-- required 必填项 -->
  19. <input
  20. type="text"
  21. id="username"
  22. name="username"
  23. value=""
  24. placeholder="请输入用户名"
  25. autofocus
  26. required
  27. />
  28. </div>
  29. <div>
  30. <!-- password密码类型 -->
  31. <label for="password">密&nbsp;&nbsp;&nbsp;码:</label>
  32. <input
  33. type="password"
  34. id="password"
  35. name="password"
  36. value=""
  37. placeholder="大小写字母加数字"
  38. required
  39. />
  40. </div>
  41. <div>
  42. <label for="email">邮&nbsp;&nbsp;&nbsp;箱:</label>
  43. <!-- email类型会自动校验邮箱 -->
  44. <input
  45. type="email"
  46. id="email"
  47. name="email"
  48. value=""
  49. placeholder="找回密码使用"
  50. required
  51. />
  52. </div>
  53. <div>
  54. <!-- 单选按钮 -->
  55. <label for="male">性别:</label>
  56. <!-- 所有input.name必须相同 -->
  57. <!-- checked 默认选择 label.for = input.id -->
  58. <input type="radio" name="gender" id="male" checked />
  59. <label for="male"></label>
  60. <input type="radio" name="gender" id="female" />
  61. <label for="female"></label>
  62. </div>
  63. <div>
  64. <!-- 复选框 input.name必须是一个数组 -->
  65. <label id="">爱好:</label>
  66. <input type="checkbox" name="hobbies[]" id="programmer" checked />
  67. <label for="programmer">编程</label>
  68. <input type="checkbox" name="hobbies[]" id="read" checked />
  69. <label for="read">阅读</label>
  70. <input type="checkbox" name="hobbies[]" id="painting" />
  71. <label for="painting">绘画</label>
  72. <input type="checkbox" name="hobbies[]" id="football" />
  73. <label for="football">足球</label>
  74. </div>
  75. <!-- 下拉列表 -->
  76. <label for="user">会员:</label>
  77. <select name="level" id="user">
  78. <option value="1">普通会员</option>
  79. <option value="2">金牌会员</option>
  80. <option value="3" selected>钻石会员</option>
  81. </select>
  82. <div>
  83. <button>提交</button>
  84. </div>
  85. </form>
  86. </body>
  87. </html>

二、内联框架

  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>框架</title>
  8. </head>
  9. <body>
  10. <div>
  11. <!--设置a标签中href在iframe框架中打开, a.target = iframe.name -->
  12. <a href="https://www.yejuzhi.com/" target="yejuzhi">业聚质</a>
  13. <a href="https://www.zaikun.cn" target="yejuzhi">载鲲软件</a>
  14. <iframe
  15. srcdoc="<h3 style='color:blue'>请点击左侧按钮</h3>"
  16. frameboder="1"
  17. width="300"
  18. height="200"
  19. name="yejuzhi"
  20. ></iframe>
  21. <!-- 视频文件,必须加入播放按钮: controls-->
  22. <!-- autoplay自动播放 -->
  23. <video src="xxx.mp4" controls width="500" autoplay></video>
  24. </div>
  25. <hr />
  26. <h1>后台管理系统</h1>
  27. <!-- 后台顶部 -->
  28. <div class="header">
  29. <h2>某某后台管理系统</h2>
  30. <div>
  31. <span>xxx,欢迎您!</span>
  32. <a href="">退出</a>
  33. </div>
  34. </div>
  35. <!-- 左侧导航 一键生成:ul.nav>li*6>a[href="demo$.html" target="content"]{栏目$} -->
  36. <ul class="nav">
  37. <li><a href="demo1.html" target="content">栏目1</a></li>
  38. <li><a href="demo2.html" target="content">栏目2</a></li>
  39. <li><a href="demo3.html" target="content">栏目3</a></li>
  40. <li><a href="demo4.html" target="content">栏目4</a></li>
  41. <li><a href="demo5.html" target="content">栏目5</a></li>
  42. <li><a href="demo6.html" target="content">栏目6</a></li>
  43. </ul>
  44. <!-- 右侧内容显示区 -->
  45. <iframe src="" frameborder="2" name="content"></iframe>
  46. </body>
  47. </html>

三、自定义CSS样式

  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>自定义样式</title>
  8. <!-- 引入外部样式 -->
  9. <link rel="stylesheet" href="style.css" />
  10. <!-- 模块化组件引入样式 -->
  11. <!-- <style>
  12. @import url(style.css);
  13. </style> -->
  14. </head>
  15. <body>
  16. <!-- 1.默认样式:继承自html -->
  17. <!-- 2.自定义样式:行内样式,style属性定义 -->
  18. <h1 style="color: blue">自定义样式</h1>
  19. <h1 style="color: blue">没法复用</h1>
  20. <hr />
  21. <!-- 3.自定义样式2:内部样式,style标签 -->
  22. <h1>自定义样式</h1>
  23. <h1>没法复用</h1>
  24. <h1>所有h1都定义了</h1>
  25. <style>
  26. h1 {
  27. color: red;
  28. }
  29. </style>
  30. <hr />
  31. <!-- 4.自定义样式3:文档样式 -->
  32. <h2>自定义样式</h2>
  33. <h2>复用演示</h2>
  34. <h2>所有h2都定义了</h2>
  35. </body>
  36. </html>

登录代码

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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>登陆界面</title>
  8. </head>
  9. <body>
  10. <form
  11. action="login.php"
  12. method="post"
  13. style="text-align: center; margin: 60px"
  14. >
  15. <div>
  16. <label for="username">用户名:</label>
  17. <input
  18. type="text"
  19. id="username"
  20. name="username"
  21. value=""
  22. placeholder="请输入用户名"
  23. autofocus
  24. required
  25. />
  26. </div>
  27. <div>
  28. <label for="pws">密&nbsp;&nbsp;&nbsp;码:</label>
  29. <input
  30. type="password"
  31. id="pws"
  32. name="password"
  33. value=""
  34. placeholder="大小写字母加数字组合"
  35. required
  36. />
  37. </div>
  38. <div>
  39. <button>提交</button>
  40. </div>
  41. </form>
  42. </body>
  43. </html>

内联后台

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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>内联后台</title>
  8. </head>
  9. <body>
  10. <div>
  11. <!--设置a标签中href在iframe框架中打开, a.target = iframe.name -->
  12. <a href="https://www.yejuzhi.com/" target="yejuzhi">业聚质</a>
  13. <a href="https://www.zaikun.cn" target="yejuzhi">载鲲软件</a>
  14. <iframe
  15. srcdoc="<h3 style='color:blue'>请点击左侧按钮</h3>"
  16. frameboder="1"
  17. width="300"
  18. height="200"
  19. name="yejuzhi"
  20. >
  21. </iframe>
  22. </div>
  23. </body>
  24. </html>

元素样式来源优先级

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  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>元素</title>
  8. <style>
  9. h1 {
  10. color: red;
  11. }
  12. h2 {
  13. color: aqua;
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <h2>自定义样式</h2>
  19. <h2 style="color: red">改变演示</h2>
  20. <h2>所有h2都定义了</h2>
  21. </body>
  22. </html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议