亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索
博主信息
博文 10
粉絲 0
評論 0
訪問量 12647
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
表格與表單實戰(zhàn)教程
天涯
原創(chuàng)
1480人瀏覽過

表格與表單實戰(zhàn)教程

購物車實戰(zhàn)

body主體代碼

  1. <body>
  2. <!-- 表格 -->
  3. <table>
  4. <!-- 標(biāo)題 -->
  5. <caption>
  6. 購物車
  7. </caption>
  8. <!-- 頭部 -->
  9. <thead>
  10. <tr>
  11. <th>ID</th>
  12. <th>品名</th>
  13. <th>單價/元</th>
  14. <th>單位</th>
  15. <th>數(shù)量</th>
  16. <th>金額/元</th>
  17. </tr>
  18. </thead>
  19. <!-- 主體 -->
  20. <tbody>
  21. <tr>
  22. <td>SN-1010</td>
  23. <td>MacBook Pro電腦</td>
  24. <td>18999</td>
  25. <td></td>
  26. <td>1</td>
  27. <td>18999</td>
  28. </tr>
  29. <tr>
  30. <td>SN-1020</td>
  31. <td>iPhone手機</td>
  32. <td>4999</td>
  33. <td></td>
  34. <td>2</td>
  35. <td>9998</td>
  36. </tr>
  37. <tr>
  38. <td>SN-1030</td>
  39. <td>智能AI音箱</td>
  40. <td>399</td>
  41. <td></td>
  42. <td>5</td>
  43. <td>1995</td>
  44. </tr>
  45. <tr>
  46. <td>SN-1040</td>
  47. <td>SSD移動硬盤</td>
  48. <td>888</td>
  49. <td></td>
  50. <td>2</td>
  51. <td>1776</td>
  52. </tr>
  53. <tr>
  54. <td>SN-1050</td>
  55. <td>黃山毛峰</td>
  56. <td>999</td>
  57. <td></td>
  58. <td>3</td>
  59. <td>2997</td>
  60. </tr>
  61. </tbody>
  62. <!-- 底部 -->
  63. <tfoot>
  64. <tr>
  65. <td colspan="4">總計:</td>
  66. <td>13</td>
  67. <td>35765</td>
  68. </tr>
  69. </tfoot>
  70. </table>
  71. <!-- 結(jié)算按鈕 -->
  72. <div>
  73. <button>結(jié)算</button>
  74. </div>
  75. </body>

樣式代碼

  1. <style>
  2. html {
  3. font-size: 14px;
  4. }
  5. table {
  6. /* 去掉間隙 */
  7. border-collapse: collapse;
  8. /* 寬度設(shè)置為窗口的70% */
  9. width: 70%;
  10. /* 橫向居中 */
  11. margin: auto;
  12. color: #666;
  13. /* 字體變細 */
  14. font-weight: lighter;
  15. /* 文體居中 */
  16. text-align: center;
  17. }
  18. /* 為單元格添加邊框 th為頭單元格,td為表體單元格 */
  19. table thead th,
  20. table td {
  21. /* 添加底邊框 線粗1px,solid 實線 */
  22. border-bottom: 1px solid #ccc;
  23. /* 內(nèi)邊柜 */
  24. padding: 10px;
  25. }
  26. /* 標(biāo)題樣式 */
  27. table caption {
  28. /* rem指原始字體的倍數(shù),如原始字體為14px,則1.5rem=14px*1.5=21px */
  29. font-size: 1.5rem;
  30. /* 外邊柜,這里以table thead 作為參照物 */
  31. margin-bottom: 15px;
  32. color: green;
  33. }
  34. /* 設(shè)置表頭欄字體及顏色 */
  35. table th {
  36. font-weight: lighter;
  37. color: green;
  38. }
  39. /* 設(shè)置表頭欄背景色 */
  40. table thead tr:first-of-type {
  41. background-color: cyan;
  42. }
  43. /* 設(shè)置偶數(shù)行為背景色為黃色 */
  44. table tbody tr:nth-of-type(even) {
  45. background-color: yellow;
  46. }
  47. /* 設(shè)置鼠標(biāo)移動到行的懸停效果 移上變換背景色為粉色*/
  48. table tbody tr:hover {
  49. background-color: pink;
  50. }
  51. /* 設(shè)置表底樣式 */
  52. table tfoot td {
  53. /* 不顯示底部邊框 */
  54. border-bottom: none;
  55. color: coral;
  56. font-size: 1.2rem;
  57. font-weight: bolder;
  58. }
  59. /* 結(jié)算按鈕 */
  60. /* 用分組結(jié)構(gòu)選擇器取最后一個DIV */
  61. body div:last-of-type {
  62. width: 70%;
  63. margin: 10px auto;
  64. }
  65. /* 用分組結(jié)構(gòu)選擇器取第一個DIV 因文檔body中只有一個div,所以和最后一個div是同一個*/
  66. body div:first-of-type button {
  67. /* 元素靠右,相對父元素 */
  68. float: right;
  69. width: 120px;
  70. height: 32px;
  71. background-color: seagreen;
  72. color: white;
  73. border: none;
  74. /* cursor設(shè)置鼠標(biāo)樣式,pointer為手狀 */
  75. cursor: pointer;
  76. }
  77. /* 設(shè)置按鈕鼠標(biāo)懸停樣式 */
  78. body div:first-of-type button:hover {
  79. background-color: coral;
  80. font-size: 1.1rem;
  81. }
  82. </style>

顯示效果

購物車實戰(zhàn)


登錄界面實戰(zhàn)

body主體代碼

  1. <body>
  2. <h3>用戶注冊</h3>
  3. <!-- form+input.... -->
  4. <!-- form:表單固定元素名,action提交目標(biāo),method為提交方式,常用的值有post、get -->
  5. <form action="" method="POST">
  6. <!--fieldset 控件組 -->
  7. <fieldset>
  8. <!-- legeng為本控件組定義個標(biāo)題,與fieldset配合使用,不用legeng,默認為無標(biāo)題 -->
  9. <legend>基本信息(必填)</legend>
  10. <div>
  11. <!-- label:標(biāo)簽控件,for屬性的值為需綁定控件的ID值,可以與其它控件綁定,綁定后,點擊label控件,
  12. 則焦點轉(zhuǎn)換到被綁定的控件上。for為空時則不綁定任何控件,獨立顯示,點擊無效 -->
  13. <label for="my-username">賬號:</label>
  14. <!-- input:文本錄入控件
  15. type常用屬性值:text(文本)、email(郵箱)、password(密碼)、date(日期)、radio(單選框)、
  16. checkbox(復(fù)選框)、search(搜索框,與datalist配合使用時,可顯示下拉提示效果) -->
  17. <input
  18. type="text"
  19. id="my-username"
  20. name="username"
  21. placeholder="6-15位字符"
  22. autofocus
  23. />
  24. </div>
  25. <div>
  26. <label for="email-id">郵箱:</label>
  27. <input
  28. type="email"
  29. name="email"
  30. id="email-id"
  31. placeholder="demo@example.com"
  32. />
  33. </div>
  34. <!-- 密碼 -->
  35. <div>
  36. <label for="pwd-1">密碼:</label>
  37. <!-- placeholder顯示提示條件,當(dāng)文本框為空值時顯示 -->
  38. <input type="password"" name="password1" id="pwd-1"
  39. placeholder="不少于6位且字母+數(shù)字" />
  40. </div>
  41. <div>
  42. <label for="pwd-2">確認:</label>
  43. <input type="password" name="password2" id="pwd-2" />
  44. </div>
  45. </fieldset>
  46. <fieldset>
  47. <legend>擴展信息(選填)</legend>
  48. <div>
  49. <label
  50. >生日:
  51. <input type="date" name="birthday" />
  52. </label>
  53. </div>
  54. <!-- 以下單選按鈕用DIV包裝后,起到一組按鈕的效果 -->
  55. <div>
  56. <!-- 單選按鈕 -->
  57. <label for="secret">性別:</label>
  58. <!-- 單選按鈕中的name屬性名必須相同 -->
  59. <input type="radio" name="gender" value="male" id="male" /><label
  60. for="male"
  61. ></label
  62. >
  63. <input type="radio" name="gender" value="female" id="female" /><label
  64. for="female"
  65. ></label
  66. >
  67. <input
  68. type="radio"
  69. name="gender"
  70. value="secret"
  71. id="secret"
  72. checked
  73. /><label for="secret">保密</label>
  74. </div>
  75. <div>
  76. <!-- 復(fù)選框 -->
  77. <label for="programme">愛好</label>
  78. <!-- 因為復(fù)選框返回是一個或多個值,最方便后端用數(shù)組來處理, 所以將name名稱設(shè)置為數(shù)組形式便于后端腳本處理 -->
  79. <!-- checkbox的name屬性值強烈建議加“[]”,為后端處理做準(zhǔn)備 -->
  80. <input type="checkbox" name="hobby[]" id="game" value="game" /><label
  81. for="game"
  82. >打游戲</label
  83. >
  84. <!-- checked 默認選中 -->
  85. <input
  86. type="checkbox"
  87. name="hobby[]"
  88. value="shoot"
  89. id="shoot"
  90. /><label for="shoot">攝影</label>
  91. <input
  92. type="checkbox"
  93. name="hobby[]"
  94. value="programme"
  95. id="programme"
  96. checked
  97. /><label for="programme">編程</label>
  98. </div>
  99. <div>
  100. <!-- 選項列表 -->
  101. <label for="brand">手機:</label>
  102. <!-- search:搜索框,與下面的datalist(數(shù)據(jù)列表)配合使用,起到提示效果 -->
  103. <input type="search" list="phone" name="brand" id="brand" />
  104. <datalist id="phone">
  105. <option value="apple"> </option>
  106. <option value="huawei" label="華為"></option>
  107. <option value="mi" label="小米"> </option>
  108. </datalist>
  109. </div>
  110. </fieldset>
  111. <fieldset>
  112. <legend>其它信息(選填)</legend>
  113. <!--文件上傳-->
  114. <div>
  115. <label for="uploads">上傳頭像:</label>
  116. <input
  117. type="file"
  118. name="user_pic"
  119. id="uploads"
  120. accept="image/png, image/jpeg, image/gif"
  121. />
  122. </div>
  123. <!--文本域-->
  124. <div>
  125. <label for="resume">簡歷:</label>
  126. <!--注意文本域沒有value屬性-->
  127. <textarea
  128. name="resume"
  129. id="resume"
  130. cols="30"
  131. rows="5"
  132. placeholder="不超過100字"
  133. ></textarea>
  134. </div>
  135. </fieldset>
  136. <!-- 隱藏域, 例如用戶的Id, 注冊,登錄的時間。。。。
  137. 隱藏域是為后端取數(shù)存數(shù)準(zhǔn)備的,無須顯示但必須存在的數(shù)據(jù)可以用隱藏域
  138. 用JS控制后,也可實現(xiàn)顯示/隱藏效果 -->
  139. <input type="hidden" name="user_id" value="123" />
  140. <p>
  141. <!-- submit為提交按鈕控件,現(xiàn)在流行直接加button,不建議用submit,因樣式控制沒有button方便 -->
  142. <input type="submit" value="提交" class="btn" />
  143. <button class="btn">提交</button>
  144. </p>
  145. </form>
  146. </body>

樣式代碼

  1. <style>
  2. body {
  3. color: #555;
  4. }
  5. h3 {
  6. /* 文本居中 */
  7. text-align: center;
  8. }
  9. form {
  10. width: 450px;
  11. /* 外邊距 */
  12. margin: 30px auto;
  13. border-top: 1px solid #aaa;
  14. }
  15. form fieldset {
  16. border: 1px solid seagreen;
  17. background-color: lightcyan;
  18. box-shadow: 2px 2px 4px #bbb;
  19. border-radius: 10px;
  20. margin: 20px;
  21. }
  22. form fieldset legend {
  23. background-color: rgb(178, 231, 201);
  24. /* border-radius:給元素添加圓角邊框 */
  25. border-radius: 10px;
  26. color: seagreen;
  27. padding: 5px 15px;
  28. }
  29. form div {
  30. margin: 5px;
  31. }
  32. form p {
  33. text-align: center;
  34. }
  35. form .btn {
  36. width: 80px;
  37. height: 30px;
  38. border: none;
  39. background-color: seagreen;
  40. color: #ddd;
  41. }
  42. /* 按鈕鼠標(biāo)懸停樣式 */
  43. form .btn:hover {
  44. background-color: coral;
  45. color: white;
  46. cursor: pointer;
  47. }
  48. /* 文本框得到焦點后的樣式 */
  49. input:focus {
  50. background-color: rgb(226, 226, 175);
  51. }
  52. </style>

顯示效果

登錄界面實戰(zhàn)

批改老師:WJWJ

批改狀態(tài):合格

老師批語:寫的非常不錯,格式也工整!
本博文版權(quán)歸博主所有,轉(zhuǎn)載請注明地址!如有侵權(quán)、違法,請聯(lián)系admin@php.cn舉報處理!
全部評論 文明上網(wǎng)理性發(fā)言,請遵守新聞評論服務(wù)協(xié)議
0條評論
作者最新博文
關(guān)于我們 免責(zé)申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!
關(guān)注服務(wù)號 技術(shù)交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號

  • 登錄PHP中文網(wǎng),和優(yōu)秀的人一起學(xué)習(xí)!
    全站2000+教程免費學(xué)