{"id":1931,"date":"2025-02-22T14:12:03","date_gmt":"2025-02-22T06:12:03","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=1931"},"modified":"2025-02-22T14:12:03","modified_gmt":"2025-02-22T06:12:03","slug":"html%e5%b5%8c%e5%a5%97%e7%bb%93%e6%9e%84%e5%92%8c%e5%b8%83%e5%b1%80","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/02\/22\/html%e5%b5%8c%e5%a5%97%e7%bb%93%e6%9e%84%e5%92%8c%e5%b8%83%e5%b1%80\/","title":{"rendered":"HTML\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40"},"content":{"rendered":"\n<p>\u5728 HTML \u4e2d\uff0c\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40\u662f\u521b\u5efa\u7f51\u9875\u7684\u57fa\u7840\uff0c\u5b83\u4eec\u5e2e\u52a9\u7ec4\u7ec7\u548c\u5c55\u793a\u9875\u9762\u5185\u5bb9\u3002\u901a\u8fc7\u5408\u9002\u7684\u5e03\u5c40\u548c\u5d4c\u5957\u7ed3\u6784\uff0c\u7f51\u9875\u53ef\u4ee5\u53d8\u5f97\u66f4\u52a0\u6613\u8bfb\u548c\u6613\u7528\u3002<\/p>\n\n\n\n<p>\u5d4c\u5957\u7ed3\u6784\u6307\u7684\u662f\u5728\u4e00\u4e2a HTML \u5143\u7d20\u5185\u90e8\u5305\u542b\u53e6\u4e00\u4e2a\u5143\u7d20\uff0c\u5e03\u5c40\u5219\u662f\u901a\u8fc7 CSS \u5bf9\u5143\u7d20\u7684\u6392\u5217\u548c\u7ed3\u6784\u8fdb\u884c\u63a7\u5236\u3002\u5728\u8fd9\u4e24\u8005\u7684\u57fa\u7840\u4e0a\uff0c\u7f51\u9875\u5185\u5bb9\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u3001\u54cd\u5e94\u5f0f\u548c\u7f8e\u89c2\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u8be6\u7ec6\u8bb2\u89e3\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40\u7684\u6982\u5ff5\u548c\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. \u5d4c\u5957\u7ed3\u6784<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1.1. \u4ec0\u4e48\u662f\u5d4c\u5957\u7ed3\u6784<\/strong><\/h4>\n\n\n\n<p>\u5d4c\u5957\u7ed3\u6784\u662f\u6307\u5728 HTML \u6807\u7b7e\u5185\u5d4c\u5957\u5176\u4ed6 HTML \u6807\u7b7e\uff0c\u5f62\u6210\u5c42\u7ea7\u5173\u7cfb\u3002\u5d4c\u5957\u7684\u65b9\u5f0f\u662f\u6839\u636e\u7f51\u9875\u7684\u9700\u6c42\u8fdb\u884c\u7684\uff0c\u4e00\u822c\u901a\u8fc7\u7236\u5b50\u5173\u7cfb\u3001\u5144\u5f1f\u5173\u7cfb\u6765\u7ec4\u7ec7\u9875\u9762\u5185\u5bb9\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u4e00\u4e2a\u5305\u542b\u6807\u9898\u548c\u6bb5\u843d\u7684\u7b80\u5355\u5d4c\u5957\u7ed3\u6784\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div&gt;\n  &lt;h1&gt;\u6211\u7684\u7f51\u9875\u6807\u9898&lt;\/h1&gt;\n  &lt;p&gt;\u8fd9\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6bb5\u843d\u3002&lt;\/p&gt;\n&lt;\/div&gt;<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c<code>&lt;div&gt;<\/code> \u5143\u7d20\u662f\u7236\u5143\u7d20\uff0c\u5305\u542b\u4e86 <code>&lt;h1&gt;<\/code> \u548c <code>&lt;p&gt;<\/code> \u4e24\u4e2a\u5b50\u5143\u7d20\u3002\u8fd9\u6837\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5c06\u9875\u9762\u5143\u7d20\u8fdb\u884c\u5206\u7ec4\uff0c\u65b9\u4fbf\u5e03\u5c40\u548c\u6837\u5f0f\u63a7\u5236\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1.2. \u5e38\u89c1\u7684\u5d4c\u5957\u7ed3\u6784<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5217\u8868\u5d4c\u5957<\/strong>\uff1a\u4e00\u4e2a\u5217\u8868\u53ef\u4ee5\u5d4c\u5957\u53e6\u4e00\u4e2a\u5217\u8868\uff0c\u8fd9\u5728\u5bfc\u822a\u83dc\u5355\u4e2d\u975e\u5e38\u5e38\u89c1\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;ul&gt;\n  &lt;li&gt;\u9996\u9875&lt;\/li&gt;\n  &lt;li&gt;\u5173\u4e8e\u6211\u4eec\n    &lt;ul&gt;\n      &lt;li&gt;\u56e2\u961f\u4ecb\u7ecd&lt;\/li&gt;\n      &lt;li&gt;\u516c\u53f8\u6587\u5316&lt;\/li&gt;\n    &lt;\/ul&gt;\n  &lt;\/li&gt;\n  &lt;li&gt;\u670d\u52a1&lt;\/li&gt;\n&lt;\/ul&gt;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8868\u683c\u5d4c\u5957<\/strong>\uff1a\u8868\u683c\u4e2d\u7684\u5355\u5143\u683c\u53ef\u4ee5\u5305\u542b\u5176\u4ed6\u6807\u7b7e\uff0c\u5982\u5d4c\u5957\u8868\u683c\u6216\u5217\u8868\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;table&gt;\n  &lt;tr&gt;\n    &lt;td&gt;\n      &lt;table&gt;\n        &lt;tr&gt;&lt;td&gt;\u5d4c\u5957\u8868\u683c\u5185\u5bb9&lt;\/td&gt;&lt;\/tr&gt;\n      &lt;\/table&gt;\n    &lt;\/td&gt;\n  &lt;\/tr&gt;\n&lt;\/table&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1.3. \u5d4c\u5957\u7ed3\u6784\u7684\u6ce8\u610f\u4e8b\u9879<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5408\u7406\u5d4c\u5957<\/strong>\uff1a\u5c3d\u91cf\u907f\u514d\u8fc7\u591a\u7684\u5d4c\u5957\uff0c\u4fdd\u6301 HTML \u7ed3\u6784\u6e05\u6670\uff0c\u907f\u514d\u591a\u4f59\u7684\u5d4c\u5957\u5c42\u7ea7\u3002<\/li>\n\n\n\n<li><strong>\u8bed\u4e49\u5316<\/strong>\uff1a\u4f7f\u7528\u5408\u9002\u7684 HTML \u5143\u7d20\uff0c\u907f\u514d\u6ee5\u7528 <code>&lt;div><\/code> \u6216 <code>&lt;span><\/code>\uff0c\u6709\u65f6\u5019\u4f7f\u7528\u4e13\u95e8\u7684\u6807\u7b7e\u5982 <code>&lt;article><\/code>, <code>&lt;section><\/code>, <code>&lt;nav><\/code> \u7b49\u66f4\u4e3a\u6070\u5f53\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u5e03\u5c40<\/strong><\/h3>\n\n\n\n<p>\u5e03\u5c40\u662f\u6307\u901a\u8fc7 CSS \u5bf9\u7f51\u9875\u5143\u7d20\u7684\u6392\u5217\u65b9\u5f0f\u8fdb\u884c\u63a7\u5236\uff0c\u786e\u4fdd\u9875\u9762\u5728\u4e0d\u540c\u8bbe\u5907\u548c\u5c4f\u5e55\u4e0a\u826f\u597d\u5c55\u793a\u3002\u73b0\u4ee3\u7f51\u9875\u5e03\u5c40\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u79cd\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2.1. \u4f7f\u7528 Flexbox \u5e03\u5c40<\/strong><\/h4>\n\n\n\n<p>Flexbox \u662f\u4e00\u79cd\u73b0\u4ee3\u7684\u5e03\u5c40\u65b9\u5f0f\uff0c\u53ef\u4ee5\u8ba9\u5bb9\u5668\u5185\u7684\u5143\u7d20\u5728\u6c34\u5e73\u65b9\u5411\u548c\u5782\u76f4\u65b9\u5411\u4e0a\u81ea\u9002\u5e94\u6392\u5217\uff0c\u975e\u5e38\u9002\u5408\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"flex-container\"&gt;\n  &lt;div&gt;\u9879\u76ee 1&lt;\/div&gt;\n  &lt;div&gt;\u9879\u76ee 2&lt;\/div&gt;\n  &lt;div&gt;\u9879\u76ee 3&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;style&gt;\n  .flex-container {\n    display: flex;\n    justify-content: space-between;\n  }\n  .flex-container div {\n    padding: 20px;\n    border: 1px solid #000;\n  }\n&lt;\/style&gt;<\/code><\/pre>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528\u4e86 <code>display: flex<\/code> \u5c06\u4e09\u4e2a\u5b50\u5143\u7d20\u653e\u7f6e\u5728\u540c\u4e00\u884c\uff0c\u5e76\u901a\u8fc7 <code>justify-content: space-between<\/code> \u5c06\u5b83\u4eec\u5e73\u5747\u5206\u5e03\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2.2. \u4f7f\u7528 Grid \u5e03\u5c40<\/strong><\/h4>\n\n\n\n<p>CSS Grid Layout \u63d0\u4f9b\u4e86\u4e00\u79cd\u57fa\u4e8e\u4e8c\u7ef4\u7f51\u683c\u7684\u5e03\u5c40\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5728\u6c34\u5e73\u65b9\u5411\u548c\u5782\u76f4\u65b9\u5411\u4e0a\u540c\u65f6\u63a7\u5236\u5143\u7d20\u7684\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"grid-container\"&gt;\n  &lt;div&gt;\u9879\u76ee 1&lt;\/div&gt;\n  &lt;div&gt;\u9879\u76ee 2&lt;\/div&gt;\n  &lt;div&gt;\u9879\u76ee 3&lt;\/div&gt;\n  &lt;div&gt;\u9879\u76ee 4&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;style&gt;\n  .grid-container {\n    display: grid;\n    grid-template-columns: repeat(2, 1fr);\n    grid-gap: 10px;\n  }\n  .grid-container div {\n    padding: 20px;\n    border: 1px solid #000;\n  }\n&lt;\/style&gt;<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>grid-template-columns: repeat(2, 1fr)<\/code> \u521b\u5efa\u4e86\u4e24\u4e2a\u7b49\u5bbd\u7684\u5217\uff0c<code>grid-gap<\/code> \u8bbe\u7f6e\u4e86\u5143\u7d20\u4e4b\u95f4\u7684\u95f4\u8ddd\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2.3. \u4f7f\u7528\u4f20\u7edf\u7684\u6d6e\u52a8\u5e03\u5c40<\/strong><\/h4>\n\n\n\n<p>\u867d\u7136\u73b0\u4ee3\u6d4f\u89c8\u5668\u66f4\u503e\u5411\u4e8e\u4f7f\u7528 Flexbox \u548c Grid \u5e03\u5c40\uff0c\u4f46\u6d6e\u52a8\u5e03\u5c40\u4f9d\u7136\u662f\u7ecf\u5178\u7684\u5e03\u5c40\u65b9\u6cd5\u3002\u901a\u8fc7\u5c06\u5143\u7d20\u6d6e\u52a8\uff0c\u53ef\u4ee5\u5b9e\u73b0\u6a2a\u5411\u5e03\u5c40\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"container\"&gt;\n  &lt;div class=\"item\"&gt;\u9879\u76ee 1&lt;\/div&gt;\n  &lt;div class=\"item\"&gt;\u9879\u76ee 2&lt;\/div&gt;\n  &lt;div class=\"item\"&gt;\u9879\u76ee 3&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;style&gt;\n  .container {\n    overflow: hidden;\n  }\n  .item {\n    float: left;\n    width: 30%;\n    margin-right: 2%;\n    padding: 20px;\n    border: 1px solid #000;\n  }\n&lt;\/style&gt;<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>float: left<\/code> \u4f7f\u5f97 <code>.item<\/code> \u5143\u7d20\u5e76\u6392\u663e\u793a\uff0c\u5e76\u901a\u8fc7 <code>margin-right<\/code> \u521b\u5efa\u5143\u7d20\u4e4b\u95f4\u7684\u95f4\u9694\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2.4. \u5d4c\u5957\u5e03\u5c40\u4e0e\u54cd\u5e94\u5f0f\u8bbe\u8ba1<\/strong><\/h4>\n\n\n\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u901a\u5e38\u4f1a\u4f7f\u7528\u5d4c\u5957\u5e03\u5c40\u6765\u521b\u5efa\u590d\u6742\u7684\u9875\u9762\u7ed3\u6784\u3002\u5229\u7528 Flexbox \u6216 Grid \u5e03\u5c40\uff0c\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u54cd\u5e94\u5f0f\u8bbe\u8ba1\uff0c\u786e\u4fdd\u9875\u9762\u5728\u4e0d\u540c\u8bbe\u5907\u4e0a\u826f\u597d\u5c55\u793a\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u54cd\u5e94\u5f0f\u7684\u4e09\u5217\u5e03\u5c40\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div class=\"container\"&gt;\n  &lt;div class=\"sidebar\"&gt;\u4fa7\u8fb9\u680f&lt;\/div&gt;\n  &lt;div class=\"content\"&gt;\u4e3b\u8981\u5185\u5bb9&lt;\/div&gt;\n  &lt;div class=\"sidebar\"&gt;\u4fa7\u8fb9\u680f&lt;\/div&gt;\n&lt;\/div&gt;\n\n&lt;style&gt;\n  .container {\n    display: grid;\n    grid-template-columns: 1fr 3fr 1fr;\n    gap: 20px;\n  }\n  .sidebar {\n    background: lightgray;\n    padding: 10px;\n  }\n  .content {\n    background: lightblue;\n    padding: 10px;\n  }\n  @media screen and (max-width: 768px) {\n    .container {\n      grid-template-columns: 1fr;\n    }\n  }\n&lt;\/style&gt;<\/code><\/pre>\n\n\n\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u4f7f\u7528\u4e86 CSS Grid \u521b\u5efa\u4e00\u4e2a\u4e09\u5217\u5e03\u5c40\uff0c\u5e76\u5728\u5c4f\u5e55\u5bbd\u5ea6\u5c0f\u4e8e 768px \u65f6\u901a\u8fc7\u5a92\u4f53\u67e5\u8be2\u8c03\u6574\u4e3a\u5355\u5217\u5e03\u5c40\uff0c\u4ece\u800c\u5b9e\u73b0\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. \u603b\u7ed3<\/strong><\/h3>\n\n\n\n<p>\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40\u662f\u6784\u5efa\u7f51\u9875\u7684\u6838\u5fc3\uff0c\u5408\u9002\u7684\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40\u65b9\u6cd5\u4e0d\u4ec5\u80fd\u63d0\u9ad8\u7f51\u9875\u7684\u53ef\u8bfb\u6027\u548c\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u80fd\u786e\u4fdd\u9875\u9762\u5728\u4e0d\u540c\u8bbe\u5907\u4e0a\u826f\u597d\u7684\u5c55\u793a\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5d4c\u5957\u7ed3\u6784<\/strong>\uff1a\u901a\u8fc7\u5408\u7406\u7684 HTML \u6807\u7b7e\u5d4c\u5957\uff0c\u53ef\u4ee5\u7ec4\u7ec7\u548c\u5206\u7ec4\u9875\u9762\u5185\u5bb9\uff0c\u4f7f\u9875\u9762\u5c42\u6b21\u6e05\u6670\u3001\u8bed\u4e49\u5316\u3002<\/li>\n\n\n\n<li><strong>\u5e03\u5c40\u65b9\u6cd5<\/strong>\uff1a\u73b0\u4ee3\u5e03\u5c40\u6280\u672f\uff08\u5982 Flexbox\u3001Grid\uff09\u8ba9\u9875\u9762\u5e03\u5c40\u53d8\u5f97\u7075\u6d3b\u548c\u6613\u4e8e\u63a7\u5236\uff0c\u800c\u4f20\u7edf\u5e03\u5c40\u65b9\u6cd5\uff08\u5982\u6d6e\u52a8\u5e03\u5c40\uff09\u5728\u7279\u5b9a\u60c5\u51b5\u4e0b\u4f9d\u7136\u9002\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u901a\u8fc7\u5408\u7406\u4f7f\u7528\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40\u6280\u672f\uff0c\u53ef\u4ee5\u521b\u5efa\u66f4\u52a0\u9ad8\u6548\u548c\u54cd\u5e94\u5f0f\u7684\u7f51\u9875\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 HTML \u4e2d\uff0c\u5d4c\u5957\u7ed3\u6784\u548c\u5e03\u5c40\u662f\u521b\u5efa\u7f51\u9875\u7684\u57fa\u7840\uff0c\u5b83\u4eec\u5e2e\u52a9\u7ec4\u7ec7\u548c\u5c55\u793a\u9875\u9762\u5185\u5bb9\u3002\u901a\u8fc7\u5408\u9002\u7684\u5e03\u5c40\u548c\u5d4c\u5957\u7ed3\u6784\uff0c\u7f51\u9875\u53ef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"class_list":["post-1931","post","type-post","status-publish","format-standard","hentry","category-html"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=1931"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1931\/revisions"}],"predecessor-version":[{"id":1932,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1931\/revisions\/1932"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=1931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=1931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=1931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}