{"id":2529,"date":"2024-11-10T15:38:56","date_gmt":"2024-11-10T07:38:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2529\/"},"modified":"2024-11-10T15:38:56","modified_gmt":"2024-11-10T07:38:56","slug":"tailwind-css-%e4%b8%ad-line-height-leading-%e5%a4%b1%e6%95%88%ef%bc%9f%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%9e%82%e7%9b%b4%e5%b1%85%e4%b8%ad%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2529\/","title":{"rendered":"Tailwind CSS \u4e2d line-height\/leading \u5931\u6548\uff1f\u5982\u4f55\u5b9e\u73b0\u5782\u76f4\u5c45\u4e2d\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173078430178823.jpg\" class=\"aligncenter\" title=\"Tailwind CSS \u4e2d line-height\/leading \u5931\u6548\uff1f\u5982\u4f55\u5b9e\u73b0\u5782\u76f4\u5c45\u4e2d\uff1f\u63d2\u56fe\" alt=\"Tailwind CSS \u4e2d line-height\/leading \u5931\u6548\uff1f\u5982\u4f55\u5b9e\u73b0\u5782\u76f4\u5c45\u4e2d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>tlwind  line-height\/leading \u5931\u6548\uff1f\u600e\u4e48\u505a\uff1f<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 Tailwind CSS \u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230 line-height \u6216 leading \u8bbe\u7f6e\u65e0\u6548\u7684\u60c5\u51b5\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u5782\u76f4\u5c45\u4e2d\u7684\u5143\u7d20\u3002<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u901a\u5e38\u662f\u7531\u4ee5\u4e0b\u539f\u56e0\u5f15\u8d77\u7684\uff1a<\/p>\n<ul>\n<li> <strong>\u9ad8\u5ea6\u503c\u4e0d\u5339\u914d\uff1a<\/strong> h-(\u503c) \u7684\u5b9e\u9645\u503c\u53ef\u80fd\u4e0e leading-(\u503c) \u7c7b\u6240\u751f\u6210\u7684 line-height \u503c\u4e0d\u5339\u914d\u3002\u4f8b\u5982\uff0ch-12 \u7684\u5b9e\u9645\u503c\u662f height: 3rem;\uff0c\u800c leading-6 \u7684\u5b9e\u9645\u503c\u662f line-height: 1.5rem;\u3002<\/li>\n<li> <strong>leading \u503c\u8d85\u51fa\u8303\u56f4\uff1a<\/strong> leading \u7c7b\u53ea\u6709\u5230 leading-10 \u7684\u6700\u5927\u503c\uff0c\u56e0\u6b64\u6ca1\u6709 leading-12\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u5782\u76f4\u5c45\u4e2d\u5143\u7d20\u7684\u51e0\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li> <strong>\u4f7f\u7528 items-center \u548c justify-center\uff1a<\/strong> \u8fd9\u5c06\u6c34\u5e73\u548c\u5782\u76f4\u5c45\u4e2d\u5757\u7ea7\u5143\u7d20\u5185\u7684\u5b50\u5143\u7d20\u3002<\/li>\n<\/ul>\n<pre>&lt;nav class=\"nav h-12 w-full\"&gt;\n  &lt;div class=\"container mx-auto flex\"&gt;\n    &lt;div class=\"flex h-12 w-24 items-center justify-center hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/div&gt;\n    &lt;p class=\"flex h-12 w-24 items-center justify-center hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/p&gt;\n    &lt;span class=\"flex h-12 w-24 items-center justify-center hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/span&gt;\n  &lt;\/div&gt;\n&lt;\/nav&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>\u7f29\u5c0f\u9ad8\u5ea6\u503c\uff1a<\/strong> \u5982\u679c\u53ef\u80fd\uff0c\u53ef\u4ee5\u5c06\u9ad8\u5ea6\u503c\u7f29\u5c0f\u5230\u4e0e leading \u7c7b\u5bf9\u5e94\u7684\u503c\u3002<\/li>\n<\/ul>\n<pre>&lt;nav class=\"nav h-10 w-full\"&gt;\n  &lt;div class=\"container mx-auto flex\"&gt;\n    &lt;div class=\"h-10 w-24 text-center leading-10 hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/div&gt;\n    &lt;p class=\"h-10 w-24 text-center leading-10 hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/p&gt;\n    &lt;span class=\"h-10 w-24 text-center leading-10 hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/span&gt;\n  &lt;\/div&gt;\n&lt;\/nav&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li> <strong>\u81ea\u5b9a\u4e49 leading \u7c7b\uff1a<\/strong> \u5982\u679c\u4f60\u9700\u8981\u4f7f\u7528 line-height: 2.5rem; \u8fd9\u6837\u7684\u503c\uff0c\u4f60\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684 leading \u7c7b\u3002<\/li>\n<\/ul>\n<pre>.leading-12 {\n  line-height: 2.5rem;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\u5728\u4f60\u7684\u4ee3\u7801\u4e2d\u4f7f\u7528\u5b83\uff1a<\/p>\n<pre>&lt;div class=\"h-12 w-24 text-center leading-12 hover:bg-black hover:text-white\"&gt;\u9996\u9875&lt;\/div&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fTlwind CSS \u4e2d line-height\/leading \u5931\u6548\uff1f\u5982\u4f55\u5b9e\u73b0\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tlwind line-height\/leading \u5931\u6548\uff1f\u600e\u4e48\u505a\uff1f \u5728\u4f7f\u7528 Tailwind CSS \u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230 line-height \u6216 leading \u8bbe\u7f6e\u65e0\u6548\u7684\u60c5\u51b5\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u5782\u76f4\u5c45\u4e2d\u7684\u5143\u7d20\u3002 \u8fd9\u4e2a\u95ee\u9898\u901a\u5e38\u662f\u7531\u4ee5\u4e0b\u539f\u56e0\u5f15\u8d77\u7684\uff1a \u9ad8\u5ea6\u503c\u4e0d\u5339\u914d\uff1a h-(\u503c) \u7684\u5b9e\u9645\u503c\u53ef\u80fd\u4e0e leading-(\u503c) \u7c7b\u6240\u751f\u6210\u7684 line-height \u503c\u4e0d\u5339\u914d\u3002\u4f8b\u5982\uff0ch-12 \u7684\u5b9e\u9645\u503c\u662f height: 3rem;\uff0c\u800c leading-6 \u7684\u5b9e\u9645\u503c\u662f line-height: 1.5rem;\u3002 leading \u503c\u8d85\u51fa\u8303\u56f4\uff1a leading \u7c7b\u53ea\u6709\u5230 leading-10 \u7684\u6700\u5927\u503c\uff0c\u56e0\u6b64\u6ca1\u6709 leading-12\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a \u4ee5\u4e0b\u662f\u5782\u76f4\u5c45\u4e2d\u5143\u7d20\u7684\u51e0\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4f7f\u7528 items-center \u548c justify-center\uff1a \u8fd9\u5c06\u6c34\u5e73\u548c\u5782\u76f4\u5c45\u4e2d\u5757\u7ea7\u5143\u7d20\u5185\u7684\u5b50\u5143\u7d20\u3002 &lt;nav class=&#8221;nav h-12 w-full&#8221;&gt; &lt;div class=&#8221;container mx-auto flex&#8221;&gt; &lt;div class=&#8221;flex h-12 w-24 items-center justify-center [&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-2529","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2529","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=2529"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2529\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}