{"id":53020,"date":"2024-12-03T09:53:28","date_gmt":"2024-12-03T01:53:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/53020\/"},"modified":"2024-12-03T09:53:28","modified_gmt":"2024-12-03T01:53:28","slug":"tailwindcss%e4%b8%adline-height%e5%a4%b1%e6%95%88%e7%9a%84%e5%8e%9f%e5%9b%a0%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/53020\/","title":{"rendered":"TailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>TailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f<\/h1>\n<p><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aTailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\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\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241125\/1732531898674456ba3e15b.jpg\" class=\"aligncenter\" title=\"TailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" alt=\"TailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5782\u76f4\u5c45\u4e2d\u5931\u6548\uff1ftailwindcss\u4e2d\u7684line-height<\/strong><\/p>\n<p>\u5728tailwindcss\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528line-height-*\u6216leading-*\u7c7b\u6765\u8bbe\u7f6e\u884c\u9ad8\u3002\u7136\u800c\uff0c\u6709\u65f6\u8fd9\u4e9b\u7c7b\u53ef\u80fd\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p><strong>\u539f\u56e0<\/strong><\/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>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cleading-6\u672a\u80fd\u6709\u6548\uff0c\u539f\u56e0\u5728\u4e8e\u5143\u7d20\u7684\u5b9e\u9645\u9ad8\u5ea6(<strong>3rem<\/strong>)\u5927\u4e8eline-height: 1.5rem\u3002<\/p>\n<p><strong>\u89e3\u51b3\u529e\u6cd5<\/strong><\/p>\n<p>\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff1a<\/p>\n<ul>\n<li><strong>\u8c03\u6574\u5143\u7d20\u9ad8\u5ea6\uff1a<\/strong>\u5c06h-12\u6539\u4e3ah-10\uff0c\u4f7f\u5143\u7d20\u9ad8\u5ea6\u4e0eline-height\u503c\uff082.5rem\uff09\u5339\u914d\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<ul>\n<li><strong>\u4f7f\u7528flexbox\uff1a<\/strong>\u4f7f\u7528flex\u7c7b\u6765\u5782\u76f4\u5c45\u4e2d\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><strong>\u5176\u4ed6\u63d0\u793a<\/strong><\/p>\n<ul>\n<li>tailwindcss\u7684line-height\u7c7b\u6700\u5927\u503c\u4e3aleading-10\uff0c\u56e0\u6b64\u65e0\u6cd5\u4f7f\u7528leading-12\u3002<\/li>\n<li>\u8fd8\u53ef\u4ee5\u521b\u5efa\u81ea\u5b9a\u4e49leading-12\u7c7b\u5e76\u4f7f\u7528\u5b83\u3002<\/li>\n<\/ul>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aTailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   h1z1\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u73a9\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>TailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f \u6587\u7ae0\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u300aTailwindCSS\u4e2dline-height\u5931\u6548\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01 \u5782\u76f4\u5c45\u4e2d\u5931\u6548\uff1ftailwindcss\u4e2d\u7684line-height \u5728tailwindcss\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528line-height-*\u6216leading-*\u7c7b\u6765\u8bbe\u7f6e\u884c\u9ad8\u3002\u7136\u800c\uff0c\u6709\u65f6\u8fd9\u4e9b\u7c7b\u53ef\u80fd\u65e0\u6cd5\u6b63\u5e38\u5de5\u4f5c\u3002 \u539f\u56e0 &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; \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cleading-6\u672a\u80fd\u6709\u6548\uff0c\u539f\u56e0\u5728\u4e8e\u5143\u7d20\u7684\u5b9e\u9645\u9ad8\u5ea6(3rem)\u5927\u4e8eline-height: 1.5rem\u3002 \u89e3\u51b3\u529e\u6cd5 \u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff1a \u8c03\u6574\u5143\u7d20\u9ad8\u5ea6\uff1a\u5c06h-12\u6539\u4e3ah-10\uff0c\u4f7f\u5143\u7d20\u9ad8\u5ea6\u4e0eline-height\u503c\uff082.5rem\uff09\u5339\u914d\u3002 &lt;nav class=&#8221;nav h-10 w-full&#8221;&gt; &lt;div class=&#8221;container mx-auto flex&#8221;&gt; &lt;div class=&#8221;h-10 w-24 text-center leading-10 hover:bg-black hover:text-white&#8221;&gt;\u9996\u9875&lt;\/div&gt; &lt;p class=&#8221;h-10 [&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-53020","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53020","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=53020"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/53020\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=53020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=53020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=53020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}