完整HTML模板设计.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>HTML综合学习文档</title>
  7. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  8. <style>
  9. /* 全局样式重置 */
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. box-sizing: border-box;
  14. }
  15. /* CSS变量定义 */
  16. :root {
  17. --primary: #4361ee;
  18. --secondary: #3f37c9;
  19. --accent: #4cc9f0;
  20. --light: #f8f9fa;
  21. --dark: #212529;
  22. --success: #4CAF50;
  23. --warning: #ff9800;
  24. --danger: #f44336;
  25. --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  26. --border-radius: 8px;
  27. --transition: all 0.3s ease;
  28. --text-light: #f8f9fa;
  29. --text-dark: #212529;
  30. --bg: #f5f7fa;
  31. --card-bg: #ffffff;
  32. --header-bg: #4361ee;
  33. --sidebar-bg: #f0f2f5;
  34. }
  35. .dark-theme {
  36. --bg: #1a1a2e;
  37. --card-bg: #16213e;
  38. --text-dark: #f0f0f0;
  39. --header-bg: #0f3460;
  40. --sidebar-bg: #1a1a2e;
  41. }
  42. /* 页面基础样式 */
  43. body {
  44. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  45. line-height: 1.6;
  46. color: var(--text-dark);
  47. background-color: var(--bg);
  48. min-height: 100vh;
  49. display: grid;
  50. grid-template-columns: 280px 1fr;
  51. grid-template-rows: 70px 1fr 50px;
  52. grid-template-areas:
  53. "header header"
  54. "sidebar main"
  55. "footer footer";
  56. transition: var(--transition);
  57. }
  58. /* 页头样式 */
  59. header {
  60. grid-area: header;
  61. background: var(--header-bg);
  62. color: var(--text-light);
  63. padding: 0 2rem;
  64. display: flex;
  65. justify-content: space-between;
  66. align-items: center;
  67. box-shadow: var(--shadow);
  68. z-index: 100;
  69. }
  70. .logo {
  71. font-size: 1.8rem;
  72. font-weight: bold;
  73. display: flex;
  74. align-items: center;
  75. gap: 10px;
  76. }
  77. .theme-toggle {
  78. background: var(--accent);
  79. color: var(--text-dark);
  80. border: none;
  81. padding: 8px 15px;
  82. border-radius: 20px;
  83. cursor: pointer;
  84. font-weight: 500;
  85. display: flex;
  86. align-items: center;
  87. gap: 8px;
  88. transition: var(--transition);
  89. }
  90. .theme-toggle:hover {
  91. background: #3fb8da;
  92. }
  93. /* 侧边栏样式 */
  94. aside {
  95. grid-area: sidebar;
  96. background: var(--sidebar-bg);
  97. padding: 20px;
  98. overflow-y: auto;
  99. border-right: 1px solid rgba(0,0,0,0.1);
  100. }
  101. .sidebar-section {
  102. margin-bottom: 25px;
  103. }
  104. .sidebar-section h3 {
  105. color: var(--primary);
  106. margin-bottom: 15px;
  107. padding-bottom: 8px;
  108. border-bottom: 2px solid var(--accent);
  109. }
  110. .sidebar-links {
  111. list-style: none;
  112. }
  113. .sidebar-links li {
  114. margin-bottom: 8px;
  115. }
  116. .sidebar-links a {
  117. text-decoration: none;
  118. color: var(--text-dark);
  119. display: block;
  120. padding: 8px 12px;
  121. border-radius: var(--border-radius);
  122. transition: var(--transition);
  123. }
  124. .sidebar-links a:hover {
  125. background: var(--primary);
  126. color: white;
  127. }
  128. .sidebar-links a i {
  129. width: 25px;
  130. text-align: center;
  131. }
  132. /* 主内容区样式 */
  133. main {
  134. grid-area: main;
  135. padding: 2rem;
  136. overflow-y: auto;
  137. }
  138. .section-card {
  139. background: var(--card-bg);
  140. border-radius: var(--border-radius);
  141. box-shadow: var(--shadow);
  142. padding: 1.8rem;
  143. margin-bottom: 2rem;
  144. transition: var(--transition);
  145. }
  146. .section-card h2 {
  147. color: var(--primary);
  148. margin-bottom: 1.5rem;
  149. padding-bottom: 0.8rem;
  150. border-bottom: 2px solid var(--accent);
  151. display: flex;
  152. align-items: center;
  153. gap: 10px;
  154. }
  155. .section-card h3 {
  156. color: var(--secondary);
  157. margin: 1.2rem 0 0.8rem;
  158. }
  159. /* 表格样式 */
  160. table {
  161. width: 100%;
  162. border-collapse: collapse;
  163. margin: 1.2rem 0;
  164. background: var(--card-bg);
  165. box-shadow: var(--shadow);
  166. border-radius: var(--border-radius);
  167. overflow: hidden;
  168. }
  169. table th, table td {
  170. padding: 0.9rem;
  171. text-align: left;
  172. border-bottom: 1px solid rgba(0,0,0,0.1);
  173. }
  174. table th {
  175. background-color: var(--primary);
  176. color: white;
  177. }
  178. table tr:hover {
  179. background-color: rgba(0,0,0,0.03);
  180. }
  181. /* 表单样式 */
  182. .form-group {
  183. margin-bottom: 1.2rem;
  184. }
  185. label {
  186. display: block;
  187. margin-bottom: 0.5rem;
  188. font-weight: 500;
  189. }
  190. input, select, textarea {
  191. width: 100%;
  192. padding: 0.8rem;
  193. border: 1px solid #ddd;
  194. border-radius: var(--border-radius);
  195. font-size: 1rem;
  196. background: var(--card-bg);
  197. color: var(--text-dark);
  198. transition: var(--transition);
  199. }
  200. input:focus, select:focus, textarea:focus {
  201. border-color: var(--accent);
  202. outline: none;
  203. box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.3);
  204. }
  205. button, .btn {
  206. background: var(--primary);
  207. color: white;
  208. border: none;
  209. padding: 0.8rem 1.5rem;
  210. border-radius: var(--border-radius);
  211. cursor: pointer;
  212. font-size: 1rem;
  213. font-weight: 500;
  214. transition: var(--transition);
  215. display: inline-flex;
  216. align-items: center;
  217. gap: 8px;
  218. }
  219. button:hover, .btn:hover {
  220. background: var(--secondary);
  221. transform: translateY(-2px);
  222. }
  223. .btn-success {
  224. background: var(--success);
  225. }
  226. .btn-warning {
  227. background: var(--warning);
  228. }
  229. .btn-danger {
  230. background: var(--danger);
  231. }
  232. /* 列表样式 */
  233. ul, ol {
  234. margin-left: 1.8rem;
  235. margin-bottom: 1.2rem;
  236. }
  237. li {
  238. margin-bottom: 0.5rem;
  239. }
  240. /* 页脚样式 */
  241. footer {
  242. grid-area: footer;
  243. background: var(--dark);
  244. color: var(--text-light);
  245. text-align: center;
  246. padding: 1rem;
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. }
  251. /* 实用工具类 */
  252. .flex {
  253. display: flex;
  254. gap: 1rem;
  255. flex-wrap: wrap;
  256. }
  257. .grid {
  258. display: grid;
  259. grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  260. gap: 1.5rem;
  261. }
  262. .text-center {
  263. text-align: center;
  264. }
  265. .mt-2 {
  266. margin-top: 2rem;
  267. }
  268. .mb-2 {
  269. margin-bottom: 2rem;
  270. }
  271. .p-3 {
  272. padding: 1.5rem;
  273. }
  274. .example-box {
  275. background: rgba(67, 97, 238, 0.1);
  276. border-left: 4px solid var(--primary);
  277. padding: 1.2rem;
  278. margin: 1.2rem 0;
  279. border-radius: 0 var(--border-radius) var(--border-radius) 0;
  280. }
  281. .code-block {
  282. background: #2d2d2d;
  283. color: #f8f8f2;
  284. padding: 1.2rem;
  285. border-radius: var(--border-radius);
  286. margin: 1.2rem 0;
  287. overflow: auto;
  288. font-family: 'Courier New', monospace;
  289. }
  290. .tag-example {
  291. background: var(--light);
  292. padding: 15px;
  293. border-radius: var(--border-radius);
  294. margin: 15px 0;
  295. }
  296. /* 响应式设计 */
  297. @media (max-width: 900px) {
  298. body {
  299. grid-template-columns: 1fr;
  300. grid-template-areas:
  301. "header"
  302. "main"
  303. "footer";
  304. }
  305. aside {
  306. display: none;
  307. }
  308. .mobile-menu-btn {
  309. display: block;
  310. }
  311. }
  312. @media (max-width: 600px) {
  313. .flex {
  314. flex-direction: column;
  315. }
  316. .grid {
  317. grid-template-columns: 1fr;
  318. }
  319. }
  320. </style>
  321. </head>
  322. <body>
  323. <!-- 页头区域 -->
  324. <header>
  325. <div class="logo">
  326. <i class="fab fa-html5"></i>
  327. <span>HTML综合学习文档</span>
  328. </div>
  329. <button class="theme-toggle" id="themeToggle">
  330. <i class="fas fa-moon"></i>
  331. <span>暗色模式</span>
  332. </button>
  333. </header>
  334. <!-- 侧边栏导航 -->
  335. <aside>
  336. <div class="sidebar-section">
  337. <h3><i class="fas fa-book"></i> HTML基础</h3>
  338. <ul class="sidebar-links">
  339. <li><a href="#basic-structure"><i class="fas fa-code"></i> 基本结构标签</a></li>
  340. <li><a href="#text-tags"><i class="fas fa-heading"></i> 文本标签</a></li>
  341. <li><a href="#multimedia"><i class="fas fa-image"></i> 多媒体标签</a></li>
  342. <li><a href="#links"><i class="fas fa-link"></i> 超链接标签</a></li>
  343. <li><a href="#tables"><i class="fas fa-table"></i> 表格标签</a></li>
  344. <li><a href="#lists"><i class="fas fa-list"></i> 列表标签</a></li>
  345. </ul>
  346. </div>
  347. <div class="sidebar-section">
  348. <h3><i class="fas fa-edit"></i> 表单元素</h3>
  349. <ul class="sidebar-links">
  350. <li><a href="#forms"><i class="fas fa-window-maximize"></i> 表单基础</a></li>
  351. <li><a href="#inputs"><i class="fas fa-keyboard"></i> 输入类型</a></li>
  352. <li><a href="#html5-forms"><i class="fab fa-html5"></i> HTML5表单</a></li>
  353. </ul>
  354. </div>
  355. <div class="sidebar-section">
  356. <h3><i class="fas fa-star"></i> HTML5特性</h3>
  357. <ul class="sidebar-links">
  358. <li><a href="#html5-tags"><i class="fas fa-tags"></i> 语义化标签</a></li>
  359. <li><a href="#html5-media"><i class="fas fa-play-circle"></i> 音视频</a></li>
  360. <li><a href="#html5-apis"><i class="fas fa-cogs"></i> 新API</a></li>
  361. </ul>
  362. </div>
  363. </aside>
  364. <!-- 主内容区域 -->
  365. <main>
  366. <!-- HTML基本结构 -->
  367. <section id="basic-structure" class="section-card">
  368. <h2><i class="fas fa-code"></i> HTML基本结构标签</h2>
  369. <table>
  370. <thead>
  371. <tr>
  372. <th>标签名</th>
  373. <th>定义</th>
  374. <th>说明</th>
  375. </tr>
  376. </thead>
  377. <tbody>
  378. <tr>
  379. <td>&lt;html&gt;&lt;/html&gt;</td>
  380. <td>HTML标签</td>
  381. <td>页面中最大的标签,称为根标签</td>
  382. </tr>
  383. <tr>
  384. <td>&lt;head&gt;&lt;/head&gt;</td>
  385. <td>文档的头部</td>
  386. <td>必须设置title标签</td>
  387. </tr>
  388. <tr>
  389. <td>&lt;title&gt;&lt;/title&gt;</td>
  390. <td>文档的标题</td>
  391. <td>页面标题</td>
  392. </tr>
  393. <tr>
  394. <td>&lt;body&gt;&lt;/body&gt;</td>
  395. <td>文档的主体</td>
  396. <td>包含文档的所有内容</td>
  397. </tr>
  398. </tbody>
  399. </table>
  400. <h3>基本结构示例:</h3>
  401. <div class="code-block">
  402. &lt;!DOCTYPE html&gt;
  403. &lt;html lang="zh-CN"&gt;
  404. &lt;head&gt;
  405. &lt;meta charset="UTF-8"&gt;
  406. &lt;title&gt;页面标题&lt;/title&gt;
  407. &lt;/head&gt;
  408. &lt;body&gt;
  409. &lt;h1&gt;我的第一个网页&lt;/h1&gt;
  410. &lt;p&gt;欢迎来到我的网站!&lt;/p&gt;
  411. &lt;/body&gt;
  412. &lt;/html&gt;
  413. </div>
  414. </section>
  415. <!-- 文本标签 -->
  416. <section id="text-tags" class="section-card">
  417. <h2><i class="fas fa-heading"></i> 文本标签</h2>
  418. <h3>标题标签 &lt;h1&gt; 到 &lt;h6&gt;</h3>
  419. <div class="tag-example">
  420. <h1>一级标题</h1>
  421. <h2>二级标题</h2>
  422. <h3>三级标题</h3>
  423. <h4>四级标题</h4>
  424. <h5>五级标题</h5>
  425. <h6>六级标题</h6>
  426. </div>
  427. <h3>文本格式化标签</h3>
  428. <table>
  429. <thead>
  430. <tr>
  431. <th>语义</th>
  432. <th>标签</th>
  433. <th>说明</th>
  434. </tr>
  435. </thead>
  436. <tbody>
  437. <tr>
  438. <td>加粗</td>
  439. <td>&lt;strong&gt; 或 &lt;b&gt;</td>
  440. <td>推荐使用 &lt;strong&gt; 语义更强烈</td>
  441. </tr>
  442. <tr>
  443. <td>倾斜</td>
  444. <td>&lt;em&gt; 或 &lt;i&gt;</td>
  445. <td>推荐使用 &lt;em&gt; 语义更强烈</td>
  446. </tr>
  447. <tr>
  448. <td>删除线</td>
  449. <td>&lt;del&gt; 或 &lt;s&gt;</td>
  450. <td>推荐使用 &lt;del&gt; 语义更强烈</td>
  451. </tr>
  452. <tr>
  453. <td>下划线</td>
  454. <td>&lt;ins&gt; 或 &lt;u&gt;</td>
  455. <td>推荐使用 &lt;ins&gt; 语义更强烈</td>
  456. </tr>
  457. </tbody>
  458. </table>
  459. <div class="tag-example">
  460. <p><strong>加粗文本</strong> 和 <b>加粗文本</b></p>
  461. <p><em>倾斜文本</em> 和 <i>倾斜文本</i></p>
  462. <p><del>删除线文本</del> 和 <s>删除线文本</s></p>
  463. <p><ins>下划线文本</ins> 和 <u>下划线文本</u></p>
  464. </div>
  465. <h3>&lt;div&gt; 和 &lt;span&gt; 标签</h3>
  466. <div class="tag-example">
  467. <div style="background: #e0e0e0; padding: 10px; margin-bottom: 10px;">
  468. 这是一个div块级元素,通常用于布局容器
  469. </div>
  470. <p>这是一段文本,其中<span style="color: red; font-weight: bold;">span元素</span>用于对文本的一部分进行样式设置。</p>
  471. </div>
  472. </section>
  473. <!-- 多媒体标签 -->
  474. <section id="multimedia" class="section-card">
  475. <h2><i class="fas fa-image"></i> 多媒体标签</h2>
  476. <h3>图像标签 &lt;img&gt;</h3>
  477. <div class="flex">
  478. <div style="flex: 1;">
  479. <h4>图像属性:</h4>
  480. <ul>
  481. <li><strong>src</strong>:图像路径(必须)</li>
  482. <li><strong>alt</strong>:替代文本(图像无法显示时)</li>
  483. <li><strong>title</strong>:悬停提示文本</li>
  484. </ul>
  485. <h4 class="mt-2">路径示例:</h4>
  486. <div class="example-box">
  487. <p>&lt;img src="image.jpg" alt="描述"&gt; <span style="color: green;">// 同一级路径</span></p>
  488. <p>&lt;img src="images/image.jpg"&gt; <span style="color: green;">// 下一级路径</span></p>
  489. <p>&lt;img src="../image.jpg"&gt; <span style="color: green;">// 上一级路径</span></p>
  490. </div>
  491. </div>
  492. <div style="flex: 1; text-align: center;">
  493. <img src="https://via.placeholder.com/300x200" alt="占位图像" title="这是一个示例图像" style="max-width: 100%; border-radius: var(--border-radius);">
  494. <p class="text-center mt-2">示例图像</p>
  495. </div>
  496. </div>
  497. <h3>音频标签 &lt;audio&gt;</h3>
  498. <div class="flex">
  499. <div style="flex: 1;">
  500. <h4>属性:</h4>
  501. <ul>
  502. <li><strong>src</strong>:音频URL(必须)</li>
  503. <li><strong>controls</strong>:显示控制面板</li>
  504. <li><strong>loop</strong>:循环播放</li>
  505. <li><strong>autoplay</strong>:自动播放</li>
  506. </ul>
  507. </div>
  508. <div style="flex: 1;">
  509. <audio controls style="width: 100%;">
  510. <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
  511. 您的浏览器不支持音频元素。
  512. </audio>
  513. </div>
  514. </div>
  515. <h3>视频标签 &lt;video&gt;</h3>
  516. <div class="flex">
  517. <div style="flex: 1;">
  518. <h4>属性:</h4>
  519. <ul>
  520. <li><strong>src</strong>:视频URL(必须)</li>
  521. <li><strong>controls</strong>:显示控制面板</li>
  522. <li><strong>muted</strong>:静音播放</li>
  523. <li><strong>loop</strong>:循环播放</li>
  524. <li><strong>autoplay</strong>:自动播放</li>
  525. <li><strong>poster</strong>:加载等待画面</li>
  526. </ul>
  527. </div>
  528. <div style="flex: 1;">
  529. <video controls width="100%" poster="https://via.placeholder.com/300x200">
  530. <source src="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
  531. 您的浏览器不支持视频元素。
  532. </video>
  533. </div>
  534. </div>
  535. </section>
  536. <!-- 表单部分 -->
  537. <section id="forms" class="section-card">
  538. <h2><i class="fas fa-window-maximize"></i> 表单元素</h2>
  539. <h3>表单域 &lt;form&gt;</h3>
  540. <table>
  541. <thead>
  542. <tr>
  543. <th>属性</th>
  544. <th>值</th>
  545. <th>作用</th>
  546. </tr>
  547. </thead>
  548. <tbody>
  549. <tr>
  550. <td>action</td>
  551. <td>url地址</td>
  552. <td>指定处理表单数据的服务器URL</td>
  553. </tr>
  554. <tr>
  555. <td>method</td>
  556. <td>get/post</td>
  557. <td>设置表单数据的提交方式</td>
  558. </tr>
  559. <tr>
  560. <td>name</td>
  561. <td>名称</td>
  562. <td>指定表单名称,区分多个表单</td>
  563. </tr>
  564. </tbody>
  565. </table>
  566. <h3>输入元素 &lt;input&gt;</h3>
  567. <form id="exampleForm" class="tag-example">
  568. <div class="form-group">
  569. <label for="username">用户名:</label>
  570. <input type="text" id="username" name="username" placeholder="请输入用户名">
  571. </div>
  572. <div class="form-group">
  573. <label for="password">密码:</label>
  574. <input type="password" id="password" name="password" placeholder="请输入密码">
  575. </div>
  576. <div class="form-group">
  577. <label>性别:</label>
  578. <div style="display: flex; gap: 15px; margin-top: 8px;">
  579. <label style="display: flex; align-items: center; gap: 5px;">
  580. <input type="radio" name="gender" value="male" checked> 男
  581. </label>
  582. <label style="display: flex; align-items: center; gap: 5px;">
  583. <input type="radio" name="gender" value="female"> 女
  584. </label>
  585. </div>
  586. </div>
  587. <div class="form-group">
  588. <label>兴趣爱好:</label>
  589. <div style="display: flex; flex-wrap: wrap; gap: 15px; margin-top: 8px;">
  590. <label style="display: flex; align-items: center; gap: 5px;">
  591. <input type="checkbox" name="hobby" value="reading"> 阅读
  592. </label>
  593. <label style="display: flex; align-items: center; gap: 5px;">
  594. <input type="checkbox" name="hobby" value="sports"> 运动
  595. </label>
  596. <label style="display: flex; align-items: center; gap: 5px;">
  597. <input type="checkbox" name="hobby" value="music"> 音乐
  598. </label>
  599. </div>
  600. </div>
  601. <div class="form-group">
  602. <label for="country">国家:</label>
  603. <select id="country" name="country">
  604. <option value="">请选择国家</option>
  605. <option value="china">中国</option>
  606. <option value="usa">美国</option>
  607. <option value="uk">英国</option>
  608. <option value="japan">日本</option>
  609. </select>
  610. </div>
  611. <div class="form-group">
  612. <label for="bio">个人简介:</label>
  613. <textarea id="bio" name="bio" rows="4" placeholder="请输入个人简介"></textarea>
  614. </div>
  615. <div class="form-group">
  616. <label for="avatar">上传头像:</label>
  617. <input type="file" id="avatar" name="avatar">
  618. </div>
  619. <div class="flex">
  620. <button type="submit" class="btn"><i class="fas fa-paper-plane"></i> 提交</button>
  621. <button type="reset" class="btn btn-danger"><i class="fas fa-redo"></i> 重置</button>
  622. <button type="button" class="btn btn-success"><i class="fas fa-download"></i> 保存</button>
  623. </div>
  624. </form>
  625. </section>
  626. <!-- HTML5特性 -->
  627. <section id="html5-tags" class="section-card">
  628. <h2><i class="fas fa-tags"></i> HTML5语义化标签</h2>
  629. <div class="tag-example" style="position: relative; height: 300px;">
  630. <header style="background: var(--primary); color: white; padding: 10px; text-align: center;">
  631. &lt;header&gt; - 页面头部
  632. </header>
  633. <nav style="background: var(--secondary); color: white; padding: 10px; margin: 10px 0;">
  634. &lt;nav&gt; - 导航栏
  635. </nav>
  636. <div style="display: flex; gap: 10px; height: 200px;">
  637. <article style="background: #e0f7fa; flex: 3; padding: 10px;">
  638. &lt;article&gt; - 主要内容
  639. <section style="background: #bbdefb; margin: 10px 0; padding: 10px;">
  640. &lt;section&gt; - 内容区块
  641. </section>
  642. </article>
  643. <aside style="background: #ffecb3; flex: 1; padding: 10px;">
  644. &lt;aside&gt; - 侧边栏
  645. </aside>
  646. </div>
  647. <footer style="background: var(--dark); color: white; padding: 10px; text-align: center; margin-top: 10px;">
  648. &lt;footer&gt; - 页脚
  649. </footer>
  650. </div>
  651. <h3>HTML5表单增强</h3>
  652. <form class="tag-example">
  653. <div class="grid">
  654. <div class="form-group">
  655. <label for="email">邮箱:</label>
  656. <input type="email" id="email" placeholder="请输入邮箱" required>
  657. </div>
  658. <div class="form-group">
  659. <label for="url">个人网站:</label>
  660. <input type="url" id="url" placeholder="请输入网址">
  661. </div>
  662. <div class="form-group">
  663. <label for="date">出生日期:</label>
  664. <input type="date" id="date">
  665. </div>
  666. <div class="form-group">
  667. <label for="color">主题色:</label>
  668. <input type="color" id="color" value="#4361ee">
  669. </div>
  670. <div class="form-group">
  671. <label for="range">音量:</label>
  672. <input type="range" id="range" min="0" max="100" value="50">
  673. </div>
  674. <div class="form-group">
  675. <label for="search">搜索:</label>
  676. <input type="search" id="search" placeholder="搜索内容">
  677. </div>
  678. </div>
  679. <button type="submit" class="btn">提交HTML5表单</button>
  680. </form>
  681. </section>
  682. </main>
  683. <!-- 页脚区域 -->
  684. <footer>
  685. <p>&copy; 2023 HTML综合学习文档 | 包含HTML5所有核心特性</p>
  686. </footer>
  687. <script>
  688. // 主题切换功能
  689. document.getElementById('themeToggle').addEventListener('click', function() {
  690. document.body.classList.toggle('dark-theme');
  691. if (document.body.classList.contains('dark-theme')) {
  692. this.innerHTML = '<i class="fas fa-sun"></i> 亮色模式';
  693. } else {
  694. this.innerHTML = '<i class="fas fa-moon"></i> 暗色模式';
  695. }
  696. });
  697. // 表单提交演示
  698. document.getElementById('exampleForm').addEventListener('submit', function(e) {
  699. e.preventDefault();
  700. alert('表单已提交(演示功能)');
  701. });
  702. // 页面锚点滚动
  703. document.querySelectorAll('a[href^="#"]').forEach(anchor => {
  704. anchor.addEventListener('click', function(e) {
  705. e.preventDefault();
  706. const targetId = this.getAttribute('href');
  707. if (targetId === '#') return;
  708. const targetElement = document.querySelector(targetId);
  709. if (targetElement) {
  710. window.scrollTo({
  711. top: targetElement.offsetTop - 80,
  712. behavior: 'smooth'
  713. });
  714. }
  715. });
  716. });
  717. </script>
  718. </body>
  719. </html>