123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>HTML综合学习文档</title>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
- <style>
- /* 全局样式重置 */
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- }
- /* CSS变量定义 */
- :root {
- --primary: #4361ee;
- --secondary: #3f37c9;
- --accent: #4cc9f0;
- --light: #f8f9fa;
- --dark: #212529;
- --success: #4CAF50;
- --warning: #ff9800;
- --danger: #f44336;
- --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
- --border-radius: 8px;
- --transition: all 0.3s ease;
- --text-light: #f8f9fa;
- --text-dark: #212529;
- --bg: #f5f7fa;
- --card-bg: #ffffff;
- --header-bg: #4361ee;
- --sidebar-bg: #f0f2f5;
- }
- .dark-theme {
- --bg: #1a1a2e;
- --card-bg: #16213e;
- --text-dark: #f0f0f0;
- --header-bg: #0f3460;
- --sidebar-bg: #1a1a2e;
- }
- /* 页面基础样式 */
- body {
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
- line-height: 1.6;
- color: var(--text-dark);
- background-color: var(--bg);
- min-height: 100vh;
- display: grid;
- grid-template-columns: 280px 1fr;
- grid-template-rows: 70px 1fr 50px;
- grid-template-areas:
- "header header"
- "sidebar main"
- "footer footer";
- transition: var(--transition);
- }
- /* 页头样式 */
- header {
- grid-area: header;
- background: var(--header-bg);
- color: var(--text-light);
- padding: 0 2rem;
- display: flex;
- justify-content: space-between;
- align-items: center;
- box-shadow: var(--shadow);
- z-index: 100;
- }
- .logo {
- font-size: 1.8rem;
- font-weight: bold;
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .theme-toggle {
- background: var(--accent);
- color: var(--text-dark);
- border: none;
- padding: 8px 15px;
- border-radius: 20px;
- cursor: pointer;
- font-weight: 500;
- display: flex;
- align-items: center;
- gap: 8px;
- transition: var(--transition);
- }
- .theme-toggle:hover {
- background: #3fb8da;
- }
- /* 侧边栏样式 */
- aside {
- grid-area: sidebar;
- background: var(--sidebar-bg);
- padding: 20px;
- overflow-y: auto;
- border-right: 1px solid rgba(0,0,0,0.1);
- }
- .sidebar-section {
- margin-bottom: 25px;
- }
- .sidebar-section h3 {
- color: var(--primary);
- margin-bottom: 15px;
- padding-bottom: 8px;
- border-bottom: 2px solid var(--accent);
- }
- .sidebar-links {
- list-style: none;
- }
- .sidebar-links li {
- margin-bottom: 8px;
- }
- .sidebar-links a {
- text-decoration: none;
- color: var(--text-dark);
- display: block;
- padding: 8px 12px;
- border-radius: var(--border-radius);
- transition: var(--transition);
- }
- .sidebar-links a:hover {
- background: var(--primary);
- color: white;
- }
- .sidebar-links a i {
- width: 25px;
- text-align: center;
- }
- /* 主内容区样式 */
- main {
- grid-area: main;
- padding: 2rem;
- overflow-y: auto;
- }
- .section-card {
- background: var(--card-bg);
- border-radius: var(--border-radius);
- box-shadow: var(--shadow);
- padding: 1.8rem;
- margin-bottom: 2rem;
- transition: var(--transition);
- }
- .section-card h2 {
- color: var(--primary);
- margin-bottom: 1.5rem;
- padding-bottom: 0.8rem;
- border-bottom: 2px solid var(--accent);
- display: flex;
- align-items: center;
- gap: 10px;
- }
- .section-card h3 {
- color: var(--secondary);
- margin: 1.2rem 0 0.8rem;
- }
- /* 表格样式 */
- table {
- width: 100%;
- border-collapse: collapse;
- margin: 1.2rem 0;
- background: var(--card-bg);
- box-shadow: var(--shadow);
- border-radius: var(--border-radius);
- overflow: hidden;
- }
- table th, table td {
- padding: 0.9rem;
- text-align: left;
- border-bottom: 1px solid rgba(0,0,0,0.1);
- }
- table th {
- background-color: var(--primary);
- color: white;
- }
- table tr:hover {
- background-color: rgba(0,0,0,0.03);
- }
- /* 表单样式 */
- .form-group {
- margin-bottom: 1.2rem;
- }
- label {
- display: block;
- margin-bottom: 0.5rem;
- font-weight: 500;
- }
- input, select, textarea {
- width: 100%;
- padding: 0.8rem;
- border: 1px solid #ddd;
- border-radius: var(--border-radius);
- font-size: 1rem;
- background: var(--card-bg);
- color: var(--text-dark);
- transition: var(--transition);
- }
- input:focus, select:focus, textarea:focus {
- border-color: var(--accent);
- outline: none;
- box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.3);
- }
- button, .btn {
- background: var(--primary);
- color: white;
- border: none;
- padding: 0.8rem 1.5rem;
- border-radius: var(--border-radius);
- cursor: pointer;
- font-size: 1rem;
- font-weight: 500;
- transition: var(--transition);
- display: inline-flex;
- align-items: center;
- gap: 8px;
- }
- button:hover, .btn:hover {
- background: var(--secondary);
- transform: translateY(-2px);
- }
- .btn-success {
- background: var(--success);
- }
- .btn-warning {
- background: var(--warning);
- }
- .btn-danger {
- background: var(--danger);
- }
- /* 列表样式 */
- ul, ol {
- margin-left: 1.8rem;
- margin-bottom: 1.2rem;
- }
- li {
- margin-bottom: 0.5rem;
- }
- /* 页脚样式 */
- footer {
- grid-area: footer;
- background: var(--dark);
- color: var(--text-light);
- text-align: center;
- padding: 1rem;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- /* 实用工具类 */
- .flex {
- display: flex;
- gap: 1rem;
- flex-wrap: wrap;
- }
- .grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
- gap: 1.5rem;
- }
- .text-center {
- text-align: center;
- }
- .mt-2 {
- margin-top: 2rem;
- }
- .mb-2 {
- margin-bottom: 2rem;
- }
- .p-3 {
- padding: 1.5rem;
- }
- .example-box {
- background: rgba(67, 97, 238, 0.1);
- border-left: 4px solid var(--primary);
- padding: 1.2rem;
- margin: 1.2rem 0;
- border-radius: 0 var(--border-radius) var(--border-radius) 0;
- }
- .code-block {
- background: #2d2d2d;
- color: #f8f8f2;
- padding: 1.2rem;
- border-radius: var(--border-radius);
- margin: 1.2rem 0;
- overflow: auto;
- font-family: 'Courier New', monospace;
- }
- .tag-example {
- background: var(--light);
- padding: 15px;
- border-radius: var(--border-radius);
- margin: 15px 0;
- }
- /* 响应式设计 */
- @media (max-width: 900px) {
- body {
- grid-template-columns: 1fr;
- grid-template-areas:
- "header"
- "main"
- "footer";
- }
-
- aside {
- display: none;
- }
-
- .mobile-menu-btn {
- display: block;
- }
- }
- @media (max-width: 600px) {
- .flex {
- flex-direction: column;
- }
-
- .grid {
- grid-template-columns: 1fr;
- }
- }
- </style>
- </head>
- <body>
- <!-- 页头区域 -->
- <header>
- <div class="logo">
- <i class="fab fa-html5"></i>
- <span>HTML综合学习文档</span>
- </div>
- <button class="theme-toggle" id="themeToggle">
- <i class="fas fa-moon"></i>
- <span>暗色模式</span>
- </button>
- </header>
-
- <!-- 侧边栏导航 -->
- <aside>
- <div class="sidebar-section">
- <h3><i class="fas fa-book"></i> HTML基础</h3>
- <ul class="sidebar-links">
- <li><a href="#basic-structure"><i class="fas fa-code"></i> 基本结构标签</a></li>
- <li><a href="#text-tags"><i class="fas fa-heading"></i> 文本标签</a></li>
- <li><a href="#multimedia"><i class="fas fa-image"></i> 多媒体标签</a></li>
- <li><a href="#links"><i class="fas fa-link"></i> 超链接标签</a></li>
- <li><a href="#tables"><i class="fas fa-table"></i> 表格标签</a></li>
- <li><a href="#lists"><i class="fas fa-list"></i> 列表标签</a></li>
- </ul>
- </div>
-
- <div class="sidebar-section">
- <h3><i class="fas fa-edit"></i> 表单元素</h3>
- <ul class="sidebar-links">
- <li><a href="#forms"><i class="fas fa-window-maximize"></i> 表单基础</a></li>
- <li><a href="#inputs"><i class="fas fa-keyboard"></i> 输入类型</a></li>
- <li><a href="#html5-forms"><i class="fab fa-html5"></i> HTML5表单</a></li>
- </ul>
- </div>
-
- <div class="sidebar-section">
- <h3><i class="fas fa-star"></i> HTML5特性</h3>
- <ul class="sidebar-links">
- <li><a href="#html5-tags"><i class="fas fa-tags"></i> 语义化标签</a></li>
- <li><a href="#html5-media"><i class="fas fa-play-circle"></i> 音视频</a></li>
- <li><a href="#html5-apis"><i class="fas fa-cogs"></i> 新API</a></li>
- </ul>
- </div>
- </aside>
-
- <!-- 主内容区域 -->
- <main>
- <!-- HTML基本结构 -->
- <section id="basic-structure" class="section-card">
- <h2><i class="fas fa-code"></i> HTML基本结构标签</h2>
-
- <table>
- <thead>
- <tr>
- <th>标签名</th>
- <th>定义</th>
- <th>说明</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><html></html></td>
- <td>HTML标签</td>
- <td>页面中最大的标签,称为根标签</td>
- </tr>
- <tr>
- <td><head></head></td>
- <td>文档的头部</td>
- <td>必须设置title标签</td>
- </tr>
- <tr>
- <td><title></title></td>
- <td>文档的标题</td>
- <td>页面标题</td>
- </tr>
- <tr>
- <td><body></body></td>
- <td>文档的主体</td>
- <td>包含文档的所有内容</td>
- </tr>
- </tbody>
- </table>
-
- <h3>基本结构示例:</h3>
- <div class="code-block">
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <title>页面标题</title>
- </head>
- <body>
- <h1>我的第一个网页</h1>
- <p>欢迎来到我的网站!</p>
- </body>
- </html>
- </div>
- </section>
-
- <!-- 文本标签 -->
- <section id="text-tags" class="section-card">
- <h2><i class="fas fa-heading"></i> 文本标签</h2>
-
- <h3>标题标签 <h1> 到 <h6></h3>
- <div class="tag-example">
- <h1>一级标题</h1>
- <h2>二级标题</h2>
- <h3>三级标题</h3>
- <h4>四级标题</h4>
- <h5>五级标题</h5>
- <h6>六级标题</h6>
- </div>
-
- <h3>文本格式化标签</h3>
- <table>
- <thead>
- <tr>
- <th>语义</th>
- <th>标签</th>
- <th>说明</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>加粗</td>
- <td><strong> 或 <b></td>
- <td>推荐使用 <strong> 语义更强烈</td>
- </tr>
- <tr>
- <td>倾斜</td>
- <td><em> 或 <i></td>
- <td>推荐使用 <em> 语义更强烈</td>
- </tr>
- <tr>
- <td>删除线</td>
- <td><del> 或 <s></td>
- <td>推荐使用 <del> 语义更强烈</td>
- </tr>
- <tr>
- <td>下划线</td>
- <td><ins> 或 <u></td>
- <td>推荐使用 <ins> 语义更强烈</td>
- </tr>
- </tbody>
- </table>
-
- <div class="tag-example">
- <p><strong>加粗文本</strong> 和 <b>加粗文本</b></p>
- <p><em>倾斜文本</em> 和 <i>倾斜文本</i></p>
- <p><del>删除线文本</del> 和 <s>删除线文本</s></p>
- <p><ins>下划线文本</ins> 和 <u>下划线文本</u></p>
- </div>
-
- <h3><div> 和 <span> 标签</h3>
- <div class="tag-example">
- <div style="background: #e0e0e0; padding: 10px; margin-bottom: 10px;">
- 这是一个div块级元素,通常用于布局容器
- </div>
- <p>这是一段文本,其中<span style="color: red; font-weight: bold;">span元素</span>用于对文本的一部分进行样式设置。</p>
- </div>
- </section>
-
- <!-- 多媒体标签 -->
- <section id="multimedia" class="section-card">
- <h2><i class="fas fa-image"></i> 多媒体标签</h2>
-
- <h3>图像标签 <img></h3>
- <div class="flex">
- <div style="flex: 1;">
- <h4>图像属性:</h4>
- <ul>
- <li><strong>src</strong>:图像路径(必须)</li>
- <li><strong>alt</strong>:替代文本(图像无法显示时)</li>
- <li><strong>title</strong>:悬停提示文本</li>
- </ul>
-
- <h4 class="mt-2">路径示例:</h4>
- <div class="example-box">
- <p><img src="image.jpg" alt="描述"> <span style="color: green;">// 同一级路径</span></p>
- <p><img src="images/image.jpg"> <span style="color: green;">// 下一级路径</span></p>
- <p><img src="../image.jpg"> <span style="color: green;">// 上一级路径</span></p>
- </div>
- </div>
- <div style="flex: 1; text-align: center;">
- <img src="https://via.placeholder.com/300x200" alt="占位图像" title="这是一个示例图像" style="max-width: 100%; border-radius: var(--border-radius);">
- <p class="text-center mt-2">示例图像</p>
- </div>
- </div>
-
- <h3>音频标签 <audio></h3>
- <div class="flex">
- <div style="flex: 1;">
- <h4>属性:</h4>
- <ul>
- <li><strong>src</strong>:音频URL(必须)</li>
- <li><strong>controls</strong>:显示控制面板</li>
- <li><strong>loop</strong>:循环播放</li>
- <li><strong>autoplay</strong>:自动播放</li>
- </ul>
- </div>
- <div style="flex: 1;">
- <audio controls style="width: 100%;">
- <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
- 您的浏览器不支持音频元素。
- </audio>
- </div>
- </div>
-
- <h3>视频标签 <video></h3>
- <div class="flex">
- <div style="flex: 1;">
- <h4>属性:</h4>
- <ul>
- <li><strong>src</strong>:视频URL(必须)</li>
- <li><strong>controls</strong>:显示控制面板</li>
- <li><strong>muted</strong>:静音播放</li>
- <li><strong>loop</strong>:循环播放</li>
- <li><strong>autoplay</strong>:自动播放</li>
- <li><strong>poster</strong>:加载等待画面</li>
- </ul>
- </div>
- <div style="flex: 1;">
- <video controls width="100%" poster="https://via.placeholder.com/300x200">
- <source src="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4">
- 您的浏览器不支持视频元素。
- </video>
- </div>
- </div>
- </section>
-
- <!-- 表单部分 -->
- <section id="forms" class="section-card">
- <h2><i class="fas fa-window-maximize"></i> 表单元素</h2>
-
- <h3>表单域 <form></h3>
- <table>
- <thead>
- <tr>
- <th>属性</th>
- <th>值</th>
- <th>作用</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>action</td>
- <td>url地址</td>
- <td>指定处理表单数据的服务器URL</td>
- </tr>
- <tr>
- <td>method</td>
- <td>get/post</td>
- <td>设置表单数据的提交方式</td>
- </tr>
- <tr>
- <td>name</td>
- <td>名称</td>
- <td>指定表单名称,区分多个表单</td>
- </tr>
- </tbody>
- </table>
-
- <h3>输入元素 <input></h3>
- <form id="exampleForm" class="tag-example">
- <div class="form-group">
- <label for="username">用户名:</label>
- <input type="text" id="username" name="username" placeholder="请输入用户名">
- </div>
-
- <div class="form-group">
- <label for="password">密码:</label>
- <input type="password" id="password" name="password" placeholder="请输入密码">
- </div>
-
- <div class="form-group">
- <label>性别:</label>
- <div style="display: flex; gap: 15px; margin-top: 8px;">
- <label style="display: flex; align-items: center; gap: 5px;">
- <input type="radio" name="gender" value="male" checked> 男
- </label>
- <label style="display: flex; align-items: center; gap: 5px;">
- <input type="radio" name="gender" value="female"> 女
- </label>
- </div>
- </div>
-
- <div class="form-group">
- <label>兴趣爱好:</label>
- <div style="display: flex; flex-wrap: wrap; gap: 15px; margin-top: 8px;">
- <label style="display: flex; align-items: center; gap: 5px;">
- <input type="checkbox" name="hobby" value="reading"> 阅读
- </label>
- <label style="display: flex; align-items: center; gap: 5px;">
- <input type="checkbox" name="hobby" value="sports"> 运动
- </label>
- <label style="display: flex; align-items: center; gap: 5px;">
- <input type="checkbox" name="hobby" value="music"> 音乐
- </label>
- </div>
- </div>
-
- <div class="form-group">
- <label for="country">国家:</label>
- <select id="country" name="country">
- <option value="">请选择国家</option>
- <option value="china">中国</option>
- <option value="usa">美国</option>
- <option value="uk">英国</option>
- <option value="japan">日本</option>
- </select>
- </div>
-
- <div class="form-group">
- <label for="bio">个人简介:</label>
- <textarea id="bio" name="bio" rows="4" placeholder="请输入个人简介"></textarea>
- </div>
-
- <div class="form-group">
- <label for="avatar">上传头像:</label>
- <input type="file" id="avatar" name="avatar">
- </div>
-
- <div class="flex">
- <button type="submit" class="btn"><i class="fas fa-paper-plane"></i> 提交</button>
- <button type="reset" class="btn btn-danger"><i class="fas fa-redo"></i> 重置</button>
- <button type="button" class="btn btn-success"><i class="fas fa-download"></i> 保存</button>
- </div>
- </form>
- </section>
-
- <!-- HTML5特性 -->
- <section id="html5-tags" class="section-card">
- <h2><i class="fas fa-tags"></i> HTML5语义化标签</h2>
-
- <div class="tag-example" style="position: relative; height: 300px;">
- <header style="background: var(--primary); color: white; padding: 10px; text-align: center;">
- <header> - 页面头部
- </header>
-
- <nav style="background: var(--secondary); color: white; padding: 10px; margin: 10px 0;">
- <nav> - 导航栏
- </nav>
-
- <div style="display: flex; gap: 10px; height: 200px;">
- <article style="background: #e0f7fa; flex: 3; padding: 10px;">
- <article> - 主要内容
- <section style="background: #bbdefb; margin: 10px 0; padding: 10px;">
- <section> - 内容区块
- </section>
- </article>
-
- <aside style="background: #ffecb3; flex: 1; padding: 10px;">
- <aside> - 侧边栏
- </aside>
- </div>
-
- <footer style="background: var(--dark); color: white; padding: 10px; text-align: center; margin-top: 10px;">
- <footer> - 页脚
- </footer>
- </div>
-
- <h3>HTML5表单增强</h3>
- <form class="tag-example">
- <div class="grid">
- <div class="form-group">
- <label for="email">邮箱:</label>
- <input type="email" id="email" placeholder="请输入邮箱" required>
- </div>
-
- <div class="form-group">
- <label for="url">个人网站:</label>
- <input type="url" id="url" placeholder="请输入网址">
- </div>
-
- <div class="form-group">
- <label for="date">出生日期:</label>
- <input type="date" id="date">
- </div>
-
- <div class="form-group">
- <label for="color">主题色:</label>
- <input type="color" id="color" value="#4361ee">
- </div>
-
- <div class="form-group">
- <label for="range">音量:</label>
- <input type="range" id="range" min="0" max="100" value="50">
- </div>
-
- <div class="form-group">
- <label for="search">搜索:</label>
- <input type="search" id="search" placeholder="搜索内容">
- </div>
- </div>
-
- <button type="submit" class="btn">提交HTML5表单</button>
- </form>
- </section>
- </main>
-
- <!-- 页脚区域 -->
- <footer>
- <p>© 2023 HTML综合学习文档 | 包含HTML5所有核心特性</p>
- </footer>
-
- <script>
- // 主题切换功能
- document.getElementById('themeToggle').addEventListener('click', function() {
- document.body.classList.toggle('dark-theme');
-
- if (document.body.classList.contains('dark-theme')) {
- this.innerHTML = '<i class="fas fa-sun"></i> 亮色模式';
- } else {
- this.innerHTML = '<i class="fas fa-moon"></i> 暗色模式';
- }
- });
-
- // 表单提交演示
- document.getElementById('exampleForm').addEventListener('submit', function(e) {
- e.preventDefault();
- alert('表单已提交(演示功能)');
- });
-
- // 页面锚点滚动
- document.querySelectorAll('a[href^="#"]').forEach(anchor => {
- anchor.addEventListener('click', function(e) {
- e.preventDefault();
-
- const targetId = this.getAttribute('href');
- if (targetId === '#') return;
-
- const targetElement = document.querySelector(targetId);
- if (targetElement) {
- window.scrollTo({
- top: targetElement.offsetTop - 80,
- behavior: 'smooth'
- });
- }
- });
- });
- </script>
- </body>
- </html>
|