{"id":415,"date":"2024-12-21T14:24:43","date_gmt":"2024-12-21T06:24:43","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=415"},"modified":"2024-12-21T14:24:43","modified_gmt":"2024-12-21T06:24:43","slug":"html-%e4%b8%ad%e6%bb%9a%e5%8a%a8%e6%9d%a1%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2024\/12\/21\/html-%e4%b8%ad%e6%bb%9a%e5%8a%a8%e6%9d%a1%e4%bd%bf%e7%94%a8%e6%8c%87%e5%8d%97\/","title":{"rendered":"HTML \u4e2d\u6eda\u52a8\u6761\u4f7f\u7528\u6307\u5357"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u5728 HTML \u4e2d\uff0c\u6eda\u52a8\u6761\u662f\u7528\u4e8e\u5728\u5185\u5bb9\u8d85\u51fa\u5bb9\u5668\u7684\u53ef\u89c6\u533a\u57df\u65f6\u8fdb\u884c\u6eda\u52a8\u7684\u5de5\u5177\u3002\u6eda\u52a8\u6761\u7684\u51fa\u73b0\u7531 CSS \u63a7\u5236\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5176\u663e\u793a\u6837\u5f0f\u3001\u65b9\u5411\u4ee5\u53ca\u6eda\u52a8\u884c\u4e3a\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0b\u662f\u5173\u4e8e HTML \u4e2d\u6eda\u52a8\u6761\u7684\u8be6\u7ec6\u6307\u5357\uff1a<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">1. <strong>\u6eda\u52a8\u6761\u7684\u57fa\u7840\u7528\u6cd5<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">HTML \u5143\u7d20\u9ed8\u8ba4\u4f1a\u5728\u5185\u5bb9\u8d85\u51fa\u5bb9\u5668\u8fb9\u754c\u65f6\u663e\u793a\u6eda\u52a8\u6761\uff0c\u5177\u4f53\u884c\u4e3a\u7531 <code>overflow<\/code> \u5c5e\u6027\u63a7\u5236\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong><code>overflow<\/code> \u5c5e\u6027\u503c<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u503c<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td><code>visible<\/code><\/td><td>\u9ed8\u8ba4\u503c\uff0c\u5185\u5bb9\u4e0d\u4f1a\u88ab\u88c1\u526a\uff0c\u6ea2\u51fa\u5185\u5bb9\u4f1a\u663e\u793a\u5728\u5bb9\u5668\u5916\u3002<\/td><\/tr><tr><td><code>hidden<\/code><\/td><td>\u88c1\u526a\u8d85\u51fa\u5bb9\u5668\u7684\u5185\u5bb9\uff0c\u4e0d\u663e\u793a\u6eda\u52a8\u6761\u3002<\/td><\/tr><tr><td><code>scroll<\/code><\/td><td>\u59cb\u7ec8\u663e\u793a\u6eda\u52a8\u6761\uff0c\u5373\u4f7f\u5185\u5bb9\u6ca1\u6709\u6ea2\u51fa\u3002<\/td><\/tr><tr><td><code>auto<\/code><\/td><td>\u6839\u636e\u9700\u8981\u663e\u793a\u6eda\u52a8\u6761\uff08\u5185\u5bb9\u6ea2\u51fa\u65f6\u624d\u663e\u793a\uff09\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u793a\u4f8b<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n  &lt;title&gt;\u6eda\u52a8\u6761\u793a\u4f8b&lt;\/title&gt;\n  &lt;style&gt;\n    .box {\n      width: 200px;\n      height: 100px;\n      border: 1px solid #000;\n      overflow: auto; \/* \u6839\u636e\u5185\u5bb9\u81ea\u52a8\u663e\u793a\u6eda\u52a8\u6761 *\/\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"box\"&gt;\n    \u8fd9\u662f\u4e00\u4e2a\u5185\u5bb9\u5f88\u957f\u7684\u76d2\u5b50\u3002&lt;br&gt;\n    \u6eda\u52a8\u6761\u4f1a\u5728\u5185\u5bb9\u8d85\u51fa\u76d2\u5b50\u65f6\u51fa\u73b0\u3002&lt;br&gt;\n    Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2. <strong>\u81ea\u5b9a\u4e49\u6eda\u52a8\u6761\u6837\u5f0f<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6eda\u52a8\u6761\u7684\u9ed8\u8ba4\u6837\u5f0f\u7531\u6d4f\u89c8\u5668\u51b3\u5b9a\u3002\u901a\u8fc7 CSS\uff0c\u5c24\u5176\u662f\u4f2a\u5143\u7d20 <code>::-webkit-scrollbar<\/code>\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6eda\u52a8\u6761\u6837\u5f0f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5173\u952e\u4f2a\u5143\u7d20<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u4f2a\u5143\u7d20<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td><code>::-webkit-scrollbar<\/code><\/td><td>\u6eda\u52a8\u6761\u6574\u4f53\u3002<\/td><\/tr><tr><td><code>::-webkit-scrollbar-thumb<\/code><\/td><td>\u6eda\u52a8\u6761\u4e2d\u7684\u6ed1\u5757\uff08\u53ef\u62d6\u52a8\u90e8\u5206\uff09\u3002<\/td><\/tr><tr><td><code>::-webkit-scrollbar-track<\/code><\/td><td>\u6eda\u52a8\u6761\u8f68\u9053\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u793a\u4f8b\uff1a\u81ea\u5b9a\u4e49\u6eda\u52a8\u6761<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n  &lt;title&gt;\u81ea\u5b9a\u4e49\u6eda\u52a8\u6761&lt;\/title&gt;\n  &lt;style&gt;\n    .custom-scroll {\n      width: 200px;\n      height: 150px;\n      overflow: auto;\n      border: 1px solid #ddd;\n    }\n\n    \/* \u6eda\u52a8\u6761\u6574\u4f53 *\/\n    .custom-scroll::-webkit-scrollbar {\n      width: 12px; \/* \u6eda\u52a8\u6761\u5bbd\u5ea6 *\/\n    }\n\n    \/* \u6eda\u52a8\u6761\u8f68\u9053 *\/\n    .custom-scroll::-webkit-scrollbar-track {\n      background: #f0f0f0;\n    }\n\n    \/* \u6eda\u52a8\u6761\u6ed1\u5757 *\/\n    .custom-scroll::-webkit-scrollbar-thumb {\n      background: #888;\n      border-radius: 6px;\n    }\n\n    \/* \u6ed1\u5757\u60ac\u505c\u65f6 *\/\n    .custom-scroll::-webkit-scrollbar-thumb:hover {\n      background: #555;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"custom-scroll\"&gt;\n    &lt;p&gt;\u8fd9\u91cc\u6709\u5f88\u591a\u5185\u5bb9\u9700\u8981\u6eda\u52a8\u624d\u80fd\u67e5\u770b\u3002&lt;\/p&gt;\n    &lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;\/p&gt;\n    &lt;p&gt;Curabitur vel sem et ipsum malesuada varius.&lt;\/p&gt;\n    &lt;p&gt;Integer sollicitudin venenatis nisl, nec feugiat nunc gravida ut.&lt;\/p&gt;\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3. <strong>\u9690\u85cf\u6eda\u52a8\u6761\u4f46\u4fdd\u6301\u6eda\u52a8\u529f\u80fd<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709\u65f6\u4f60\u53ef\u80fd\u5e0c\u671b\u9690\u85cf\u6eda\u52a8\u6761\uff0c\u4f46\u4ecd\u7136\u4fdd\u7559\u6eda\u52a8\u529f\u80fd\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7 CSS \u5b9e\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u793a\u4f8b\uff1a\u9690\u85cf\u6eda\u52a8\u6761<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n  &lt;title&gt;\u9690\u85cf\u6eda\u52a8\u6761&lt;\/title&gt;\n  &lt;style&gt;\n    .hidden-scroll {\n      width: 300px;\n      height: 150px;\n      overflow: auto;\n    }\n\n    \/* \u9690\u85cf\u6eda\u52a8\u6761 (\u9002\u7528\u4e8e Webkit \u6d4f\u89c8\u5668) *\/\n    .hidden-scroll::-webkit-scrollbar {\n      display: none;\n    }\n\n    \/* \u9690\u85cf\u6eda\u52a8\u6761 (\u9002\u7528\u4e8e Firefox) *\/\n    .hidden-scroll {\n      scrollbar-width: none; \/* Firefox *\/\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"hidden-scroll\"&gt;\n    \u8fd9\u662f\u9690\u85cf\u6eda\u52a8\u6761\u7684\u793a\u4f8b\uff0c\u4f46\u5185\u5bb9\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u9f20\u6807\u6216\u89e6\u6478\u8fdb\u884c\u6eda\u52a8\u3002\n    &lt;p&gt;Lorem ipsum dolor sit amet.&lt;\/p&gt;\n    &lt;p&gt;Curabitur tincidunt ligula sit amet.&lt;\/p&gt;\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4. <strong>\u6c34\u5e73\u6eda\u52a8\u6761<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6eda\u52a8\u6761\u662f\u5782\u76f4\u7684\u3002\u901a\u8fc7\u63a7\u5236\u5143\u7d20\u7684\u5bbd\u5ea6\u548c\u5185\u5bb9\u5e03\u5c40\uff0c\u53ef\u4ee5\u542f\u7528\u6c34\u5e73\u6eda\u52a8\u6761\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u793a\u4f8b\uff1a\u6c34\u5e73\u6eda\u52a8\u6761<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n  &lt;title&gt;\u6c34\u5e73\u6eda\u52a8\u6761&lt;\/title&gt;\n  &lt;style&gt;\n    .horizontal-scroll {\n      width: 200px;\n      height: 100px;\n      overflow-x: scroll; \/* \u4ec5\u663e\u793a\u6c34\u5e73\u6eda\u52a8\u6761 *\/\n      white-space: nowrap; \/* \u7981\u6b62\u5185\u5bb9\u6362\u884c *\/\n      border: 1px solid #000;\n    }\n\n    .item {\n      display: inline-block;\n      width: 150px;\n      height: 100px;\n      background-color: #f4a261;\n      margin-right: 10px;\n      text-align: center;\n      line-height: 100px;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"horizontal-scroll\"&gt;\n    &lt;div class=\"item\"&gt;1&lt;\/div&gt;\n    &lt;div class=\"item\"&gt;2&lt;\/div&gt;\n    &lt;div class=\"item\"&gt;3&lt;\/div&gt;\n    &lt;div class=\"item\"&gt;4&lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5. <strong>\u6eda\u52a8\u884c\u4e3a\u7684\u63a7\u5236<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7 CSS \u548c JavaScript\uff0c\u53ef\u4ee5\u63a7\u5236\u6eda\u52a8\u884c\u4e3a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u5e73\u6ed1\u6eda\u52a8<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528 CSS \u7684 <code>scroll-behavior<\/code> \u5c5e\u6027\u5b9e\u73b0\u6eda\u52a8\u5e73\u6ed1\u6548\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n  &lt;meta charset=\"UTF-8\"&gt;\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n  &lt;title&gt;\u5e73\u6ed1\u6eda\u52a8&lt;\/title&gt;\n  &lt;style&gt;\n    html {\n      scroll-behavior: smooth;\n    }\n    .section {\n      height: 100vh;\n      padding: 50px;\n      text-align: center;\n      border-bottom: 1px solid #ddd;\n    }\n  &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=\"section\" id=\"section1\"&gt;Section 1&lt;\/div&gt;\n  &lt;div class=\"section\" id=\"section2\"&gt;Section 2&lt;\/div&gt;\n  &lt;div class=\"section\" id=\"section3\"&gt;Section 3&lt;\/div&gt;\n  &lt;a href=\"#section3\"&gt;\u6eda\u52a8\u5230 Section 3&lt;\/a&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u7ed3\u5408 CSS \u548c JavaScript\uff0c\u4f60\u53ef\u4ee5\u7075\u6d3b\u5730\u63a7\u5236\u6eda\u52a8\u6761\u7684\u5916\u89c2\u548c\u884c\u4e3a\uff0c\u4ee5\u6ee1\u8db3\u8bbe\u8ba1\u9700\u6c42\u6216\u4f18\u5316\u7528\u6237\u4f53\u9a8c\u3002\u66f4\u591a\u8be6\u7ec6\u5185\u5bb9\u8bf7\u5173\u6ce8\u5176\u4ed6\u76f8\u5173\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 HTML \u4e2d\uff0c\u6eda\u52a8\u6761\u662f\u7528\u4e8e\u5728\u5185\u5bb9\u8d85\u51fa\u5bb9\u5668\u7684\u53ef\u89c6\u533a\u57df\u65f6\u8fdb\u884c\u6eda\u52a8\u7684\u5de5\u5177\u3002\u6eda\u52a8\u6761\u7684\u51fa\u73b0\u7531 CSS \u63a7\u5236\uff0c\u53ef\u4ee5\u81ea\u5b9a [&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-415","post","type-post","status-publish","format-standard","hentry","category-html"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/415","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=415"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/415\/revisions"}],"predecessor-version":[{"id":416,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/415\/revisions\/416"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}