个人简历网页教程

1. HTML 简介和历史

1.1 HTML 简介

HTML(HyperText Markup Language)是一种用于创建网页的标准标记语言。它通过标签(tags)来定义网页的结构和内容。

1.2 HTML 历史

HTML 最早由 Tim Berners-Lee 在 1991 年提出,经过多次版本更新,目前广泛使用的是 HTML5。

2. 开发环境搭建

2.1 文本编辑器

选择一个适合的文本编辑器,如 Visual Studio Code、Sublime Text 或 Atom。

2.2 浏览器

安装一个现代浏览器,如 Google Chrome、Mozilla Firefox 或 Microsoft Edge,用于查看和测试网页。

3. HTML 文档结构

3.1 基本结构

一个基本的 HTML 文档结构如下:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>个人简历</title>
</head>
<body>
    <h1>欢迎来到我的个人简历</h1>
</body>
</html>

3.2 解释

  • <!DOCTYPE html>: 声明文档类型为 HTML5。
  • <html>: 根元素,包含整个 HTML 文档。
  • <head>: 包含文档的元数据(meta-data),如字符集、标题等。
  • <body>: 包含网页的实际内容。

4. 常用标签和属性

4.1 常用标签

  • <h1> 到 <h6>: 标题标签。
  • <p>: 段落标签。
  • <a>: 链接标签。
  • <img>: 图片标签。

4.2 常用属性

  • href: 用于 <a> 标签,指定链接地址。
  • src: 用于 <img> 标签,指定图片路径。
  • alt: 用于 <img> 标签,提供图片的替代文本。

5. HTML5 新特性概览

5.1 新标签

  • <header>: 定义文档或节的头部。
  • <footer>: 定义文档或节的尾部。
  • <article>: 定义独立的内容块。

5.2 新属性

  • placeholder: 用于 <input> 标签,提供输入提示。
  • required: 用于 <input> 标签,表示必填字段。

6. 语义化标签

6.1 语义化标签的作用

语义化标签有助于提高代码的可读性和搜索引擎优化(SEO)。

6.2 示例

<header>
    <h1>我的个人简历</h1>
</header>
<article>
    <h2>教育背景</h2>
    <p>某某大学 计算机科学专业</p>
</article>
<footer>
    <p>© 2023 我的个人简历</p>
</footer>

7. 表单和输入元素

7.1 表单标签

<form action="/submit" method="post">
    <label for="name">姓名:</label>
    <input type="text" id="name" name="name" required>
    <button type="submit">提交</button>
</form>

7.2 输入类型

  • text: 文本输入框。
  • email: 电子邮件输入框。
  • password: 密码输入框。

8. 多媒体元素(音频、视频)

8.1 音频标签

<audio controls>
    <source src="audio.mp3" type="audio/mpeg">
    您的浏览器不支持 audio 标签。
</audio>

8.2 视频标签

<video width="320" height="240" controls>
    <source src="video.mp4" type="video/mp4">
    您的浏览器不支持 video 标签。
</video>

9. 链接和导航

9.1 内部链接

<a href="#about">关于我</a>
<section id="about">
    <h2>关于我</h2>
    <p>我是一名前端开发者。</p>
</section>

9.2 外部链接

<a href="https://www.example.com" target="_blank">访问示例网站</a>

10. 表格

10.1 基本表格

<table>
    <tr>
        <th>姓名</th>
        <th>年龄</th>
    </tr>
    <tr>
        <td>张三</td>
        <td>25</td>
    </tr>
</table>

11. 内联样式

11.1 内联样式示例

<p style="color: red; font-size: 16px;">这是一个红色的段落。</p>

12. 内部样式表

12.1 内部样式表示例

<head>
    <style>
        body {
            background-color: lightblue;
        }
        h1 {
            color: white;
            text-align: center;
        }
    </style>
</head>

13. 外部样式表

13.1 外部样式表示例

<head>
    <link rel="stylesheet" href="styles.css">
</head>

14. CSS 基础(选择器、属性、值)

14.1 选择器

  • element: 元素选择器。
  • .class: 类选择器。
  • #id: ID 选择器。

14.2 属性

  • color: 设置文本颜色。
  • font-size: 设置字体大小。
  • background-color: 设置背景颜色。

14.3 值

  • red: 颜色值。
  • 16px: 尺寸值。

15. 响应式设计基础

15.1 媒体查询

@media (max-width: 600px) {
    body {
        background-color: lightgreen;
    }
}

16. HTML5 Canvas

16.1 Canvas 示例

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
</canvas>
<script>
    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext('2d');
    ctx.fillStyle = "#FF0000";
    ctx.fillRect(0, 0, 150, 75);
</script>

17. SVG 图形

17.1 SVG 示例

<svg width="100" height="100">
    <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>

18. Web 存储(localStorage, sessionStorage)

18.1 localStorage 示例

localStorage.setItem('name', '张三');
var name = localStorage.getItem('name');
console.log(name); // 输出: 张三

19. 拖放 API

19.1 拖放示例

<div draggable="true" ondragstart="drag(event)">拖动我</div>
<div ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<script>
    function allowDrop(ev) {
        ev.preventDefault();
    }
    function drag(ev) {
        ev.dataTransfer.setData("text", ev.target.id);
    }
    function drop(ev) {
        ev.preventDefault();
        var data = ev.dataTransfer.getData("text");
        ev.target.appendChild(document.getElementById(data));
    }
</script>

20. 地理定位

20.1 地理定位示例

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
} else {
    console.log("Geolocation is not supported by this browser.");
}
function showPosition(position) {
    console.log("Latitude: " + position.coords.latitude + 
    " Longitude: " + position.coords.longitude);
}

21. ARIA 属性

21.1 ARIA 示例

<button aria-label="关闭窗口" onclick="closeWindow()">X</button>

22. 语义化结构对 SEO 的影响

22.1 语义化结构的重要性

使用语义化标签有助于搜索引擎理解网页内容,提高搜索排名。

23. 图片 alt 文本

23.1 alt 文本示例

<img src="profile.jpg" alt="我的个人照片">

24. 键盘导航

24.1 键盘导航示例

<a href="#main" tabindex="1">跳到主要内容</a>
<div id="main">
    <p>这是主要内容。</p>
</div>

25. 颜色对比度

25.1 颜色对比度示例

确保文本颜色与背景颜色有足够的对比度,以提高可读性。

26. 图片优化

26.1 图片优化示例

使用适当的图片格式(如 JPEG、PNG)和压缩工具(如 TinyPNG)来优化图片。

27. 延迟加载

27.1 延迟加载示例

<img src="placeholder.jpg" data-src="image.jpg" alt="延迟加载的图片">
<script>
    document.addEventListener("DOMContentLoaded", function() {
        var lazyImages = document.querySelectorAll("img[data-src]");
        lazyImages.forEach(function(img) {
            img.src = img.getAttribute("data-src");
        });
    });
</script>

28. 压缩和缓存

28.1 压缩和缓存示例

使用 Gzip 压缩和浏览器缓存来减少页面加载时间。

29. 关键渲染路径优化

29.1 关键渲染路径优化示例

优化 CSS 和 JavaScript 文件的加载顺序,以提高页面渲染速度。

30. 资源预加载

30.1 资源预加载示例

<link rel="preload" href="styles.css" as="style">

31. JavaScript 基础集成

31.1 JavaScript 示例

<button onclick="alert('你好,世界!')">点击我</button>

32. CSS 框架集成(Bootstrap, Tailwind)

32.1 Bootstrap 示例

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<div class="container">
    <h1 class="text-center">使用 Bootstrap 的标题</h1>
</div>

33. 模板引擎简介

33.1 模板引擎示例

使用模板引擎(如 Handlebars、EJS)来生成动态 HTML 内容。

34. 使用 CDN

34.1 CDN 示例

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>

35. 代码规范和风格指南

35.1 代码规范示例

遵循一致的代码缩进、命名约定和注释风格。

36. 跨浏览器兼容性

36.1 跨浏览器兼容性示例

使用 Polyfill 和 Modernizr 来确保代码在不同浏览器中的兼容性。

37. 移动优先设计

37.1 移动优先设计示例

body {
    font-size: 16px;
}
@media (min-width: 600px) {
    body {
        font-size: 18px;
    }
}

38. 文件组织和命名约定

38.1 文件组织示例

/project
    /css
        styles.css
    /js
        main.js
    /images
        profile.jpg
    index.html

39. 版本控制(Git 基础)

39.1 Git 示例

git init
git add .
git commit -m "初始提交"

40. 浏览器开发者工具

40.1 开发者工具示例

使用 Chrome DevTools 来调试和优化网页性能。

41. HTML 验证工具

41.1 HTML 验证工具示例

使用 W3C Markup Validation Service 来验证 HTML 代码。

42. 性能分析工具

42.1 性能分析工具示例

使用 Lighthouse 来分析网页性能。

43. 协作和版本控制工具(GitHub)

43.1 GitHub 示例

git remote add origin https://github.com/username/repository.git
git push -u origin master

44. 构建和自动化工具简介

44.1 构建工具示例

使用 Webpack 或 Gulp 来自动化构建过程。

45. 个人简历网页

45.1 个人简历网页示例

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>个人简历</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>我的个人简历</h1>
    </header>
    <section id="about">
        <h2>关于我</h2>
        <p>我是一名前端开发者,擅长 HTML、CSS 和 JavaScript。</p>
    </section>
    <section id="experience">
        <h2>工作经验</h2>
        <ul>
            <li>前端开发工程师 - 某某公司 (2018 - 至今)</li>
            <li>实习生 - 某某公司 (2017 - 2018)</li>
        </ul>
    </section>
    <footer>
        <p>© 2023 我的个人简历</p>
    </footer>
</body>
</html>

46. 响应式博客首页

46.1 响应式博客首页示例

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的博客</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>我的博客</h1>
    </header>
    <section id="posts">
        <article>
            <h2>第一篇博客</h2>
            <p>这是我的第一篇博客文章。</p>
        </article>
        <article>
            <h2>第二篇博客</h2>
            <p>这是我的第二篇博客文章。</p>
        </article>
    </section>
    <footer>
        <p>© 2023 我的博客</p>
    </footer>
</body>
</html>

47. 产品展示页面

47.1 产品展示页面示例

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>产品展示</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>产品展示</h1>