{"id":52979,"date":"2024-12-03T15:57:36","date_gmt":"2024-12-03T07:57:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52979\/"},"modified":"2024-12-03T15:57:36","modified_gmt":"2024-12-03T07:57:36","slug":"tailwind-css-%e4%b8%ad%e7%9a%84-line-height-leading-%e5%a4%b1%e6%95%88%e4%ba%86%ef%bc%9f%e5%a6%82%e4%bd%95%e8%ae%a9%e5%85%83%e7%b4%a0%e5%9e%82%e7%9b%b4%e5%b1%85%e4%b8%ad%ef%bc%9f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52979\/","title":{"rendered":"Tailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Tailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f <\/h1>\n<p>\u5077\u5077\u52aa\u529b\uff0c\u6084\u65e0\u58f0\u606f\u5730\u53d8\u5f3a\uff0c\u7136\u540e\u60ca\u8273\u6240\u6709\u4eba\uff01\u54c8\u54c8\uff0c\u5c0f\u4f19\u4f34\u4eec\u53c8\u6765\u5b66\u4e60\u5566~\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aTailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f \u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u5bf9\u5176\u90fd\u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u4e00\u5427\uff01\u5f53\u7136\uff0c\u975e\u5e38\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u8bc4\u8bba\uff0c\u7ed9\u51fa\u5408\u7406\u7684\u5efa\u8bae\uff0c\u6211\u4eec\u4e00\u8d77\u5b66\u4e60\uff0c\u4e00\u8d77\u8fdb\u6b65\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241125\/17325086756743fc037cfd3.jpg\" class=\"aligncenter\" title=\"Tailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f\u63d2\u56fe\" alt=\"Tailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>tailwindcss \u4e2d\u7684 line-height\uff08leading\uff09\u5931\u6548\u4e86\uff1f<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 Tailwind CSS \u65f6\uff0c\u53d1\u73b0 line-height\uff08leading\uff09\u6837\u5f0f\u65e0\u6548\uff0c\u5bfc\u81f4\u5143\u7d20\u65e0\u6cd5\u5782\u76f4\u5c45\u4e2d\u3002\u4e0b\u9762\u4ee5\u793a\u4f8b\u4ee3\u7801\u4e3a\u4f8b\uff0c\u8fdb\u884c\u95ee\u9898\u5206\u6790\u548c\u89e3\u51b3\uff1a<\/p>\n<pre>&lt;nav class=\"w-full nav h-12\"&gt;\n    &lt;div class=\"container mx-auto flex\"&gt;\n        &lt;div class=\"w-24 leading-6 text-center h-12 hover:bg-black\"&gt;\u9996\u9875&lt;\/div&gt;\n        &lt;p class=\"w-24 leading-6 text-center h-12 hover:bg-black\"&gt;\u9996\u9875&lt;\/p&gt;\n        &lt;span class=\"w-24 leading-6 text-center h-12 hover:bg-black\"&gt;\u9996\u9875&lt;\/span&gt;\n    &lt;\/div&gt;\n&lt;\/nav&gt;<\/pre>\n<p>\u95ee\u9898\u539f\u56e0\uff1a<\/p>\n<p>line-height \u7684\u5b9e\u9645\u503c\u662f line-height: 1.5rem\uff0c\u800c h-12 \u7684\u5b9e\u9645\u503c\u662f height: 3rem\u3002\u56e0\u6b64\uff0cline-height \u5b9e\u9645\u4e0a\u53ea\u5360\u9ad8\u5ea6\u7684\u4e00\u534a\uff0c\u5bfc\u81f4\u5143\u7d20\u65e0\u6cd5\u5c45\u4e2d\u3002<\/p>\n<p>\u6b64\u5916\uff0cTailwind CSS \u7684 leading \u503c\u6700\u5927\u4e0d\u8d85\u8fc7 leading-10\uff0c\u56e0\u6b64\u6ca1\u6709 leading-12 \u7684\u503c\u3002<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<\/p>\n<p><strong>\u4f7f\u7528\u5782\u76f4\u5c45\u4e2d\u5b9e\u7528\u7a0b\u5e8f\uff1a<\/strong><\/p>\n<p>\u5728\u5143\u7d20\u4e2d\u4f7f\u7528 items-center \u548c justify-center \u5b9e\u7528\u7a0b\u5e8f\uff0c\u5c06\u5143\u7d20\u5782\u76f4\u548c\u6c34\u5e73\u5c45\u4e2d\u3002<\/p>\n<pre>&lt;div class=\"flex h-12 w-24 items-center justify-center hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/div&gt;<\/pre>\n<p><strong>\u8c03\u6574\u9ad8\u5ea6\u503c\uff1a<\/strong><\/p>\n<p>\u5c06 h-12 \u8c03\u6574\u4e3a h-10\uff0c\u8ba9\u5143\u7d20\u7684\u9ad8\u5ea6\u4e0e leading-10 \u76f8\u5339\u914d\u3002<\/p>\n<pre>&lt;div class=\"h-10 w-24 text-center leading-10 hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/div&gt;<\/pre>\n<p><strong>\u81ea\u5b9a\u4e49 leading \u503c\uff1a<\/strong><\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7c7b\uff0c\u4f8b\u5982 .leading-12\uff0c\u5e76\u5c06 line-height \u8bbe\u7f6e\u4e3a 2.5rem\u3002<\/p>\n<pre>.leading-12 {\n  line-height: 2.5rem;\n}\n\n&lt;div class=\"w-24 leading-12 text-center h-12 hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/div&gt;<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300aTailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f \u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u63a2\u7d22\u82f9\u679c\u7535\u8111\u64ad\u653e\u5668\uff1a\u5b8c\u7f8e\u7684\u97f3\u4e50\u4e0e\u89c6\u9891\u4f53\u9a8c\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Tailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f \u5077\u5077\u52aa\u529b\uff0c\u6084\u65e0\u58f0\u606f\u5730\u53d8\u5f3a\uff0c\u7136\u540e\u60ca\u8273\u6240\u6709\u4eba\uff01\u54c8\u54c8\uff0c\u5c0f\u4f19\u4f34\u4eec\u53c8\u6765\u5b66\u4e60\u5566~\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u300aTailwind CSS \u4e2d\u7684 line-height (leading) \u5931\u6548\u4e86\uff1f\u5982\u4f55\u8ba9\u5143\u7d20\u5782\u76f4\u5c45\u4e2d\uff1f \u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u5bf9\u5176\u90fd\u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u4e00\u5427\uff01\u5f53\u7136\uff0c\u975e\u5e38\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u8bc4\u8bba\uff0c\u7ed9\u51fa\u5408\u7406\u7684\u5efa\u8bae\uff0c\u6211\u4eec\u4e00\u8d77\u5b66\u4e60\uff0c\u4e00\u8d77\u8fdb\u6b65\uff01 tailwindcss \u4e2d\u7684 line-height\uff08leading\uff09\u5931\u6548\u4e86\uff1f \u5728\u4f7f\u7528 Tailwind CSS \u65f6\uff0c\u53d1\u73b0 line-height\uff08leading\uff09\u6837\u5f0f\u65e0\u6548\uff0c\u5bfc\u81f4\u5143\u7d20\u65e0\u6cd5\u5782\u76f4\u5c45\u4e2d\u3002\u4e0b\u9762\u4ee5\u793a\u4f8b\u4ee3\u7801\u4e3a\u4f8b\uff0c\u8fdb\u884c\u95ee\u9898\u5206\u6790\u548c\u89e3\u51b3\uff1a &lt;nav class=&#8221;w-full nav h-12&#8243;&gt; &lt;div class=&#8221;container mx-auto flex&#8221;&gt; &lt;div class=&#8221;w-24 leading-6 text-center h-12 hover:bg-black&#8221;&gt;\u9996\u9875&lt;\/div&gt; &lt;p class=&#8221;w-24 leading-6 text-center h-12 hover:bg-black&#8221;&gt;\u9996\u9875&lt;\/p&gt; &lt;span class=&#8221;w-24 leading-6 text-center h-12 hover:bg-black&#8221;&gt;\u9996\u9875&lt;\/span&gt; &lt;\/div&gt; &lt;\/nav&gt; \u95ee\u9898\u539f\u56e0\uff1a line-height \u7684\u5b9e\u9645\u503c\u662f line-height: 1.5rem\uff0c\u800c h-12 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-52979","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52979"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52979\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}