{"id":1665,"date":"2024-11-10T10:18:19","date_gmt":"2024-11-10T02:18:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1665\/"},"modified":"2024-11-10T10:18:19","modified_gmt":"2024-11-10T02:18:19","slug":"less-%e4%b8%ad-calc-%e5%87%bd%e6%95%b0%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e8%83%bd%e6%b7%b7%e5%90%88%e5%8d%95%e4%bd%8d%e8%ae%a1%e7%ae%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1665\/","title":{"rendered":"Less \u4e2d calc() \u51fd\u6570\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173052900492314.jpg\" class=\"aligncenter\" title=\"Less \u4e2d calc() \u51fd\u6570\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97\uff1f\u63d2\u56fe\" alt=\"Less \u4e2d calc() \u51fd\u6570\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>less\u4e2dcalc()\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97<\/strong><\/p>\n<p>\u5728less\u4e2d\uff0c\u4f7f\u7528calc((100% &#8211; 40px) \/ 4)\u8fdb\u884c\u6df7\u5408\u5355\u4f4d\u8fd0\u7b97\u4f1a\u51fa\u73b0\u5f02\u5e38\uff0c\u7ed3\u679c\u4f1a\u88ab\u89e3\u6790\u4e3acalc(15%)\u3002<\/p>\n<p><strong>\u539f\u56e0\uff1a<\/strong><\/p>\n<p>less\u5728\u89e3\u6790calc()\u65f6\u4f1a\u5ffd\u7565\u5355\u4f4d\uff0c\u5c06\u6240\u6709\u8fd0\u7b97\u7b26\u90fd\u6309\u7167\u767e\u5206\u6bd4\u8ba1\u7b97\u3002\u56e0\u6b64\uff0c(100% &#8211; 40px)\u4f1a\u88ab\u89e3\u6790\u4e3a(100% &#8211; 40\/100%)\uff0c\u5373(100% &#8211; 40%) = 60%\u3002\u800c60% \/ 4 = 15%\uff0c\u6240\u4ee5\u7ed3\u679c\u4e3acalc(15%)\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<p>\u6709\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528\u6ce2\u6d6a\u53f7(~)\u6307\u5b9a\u53d8\u91cf\uff0c\u5982calc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\u3002\u6ce2\u6d6a\u53f7\u544a\u8bc9less\u5c06\u53d8\u91cf\u89e3\u6790\u4e3a\u503c\uff0c\u800c\u4e0d\u662f\u5355\u4f4d\u3002<\/li>\n<li>\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\u6765\u5b58\u50a8\u5355\u4f4d\uff0c\u5982@myHeight: 30px\uff0c\u7136\u540e\u4f7f\u7528calc((~&#8221;100% &#8211; @{myHeight}&#8221;) \/ 4)\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\u5c31\u662fLess \u4e2d calc() \u51fd\u6570\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97\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>less\u4e2dcalc()\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97 \u5728less\u4e2d\uff0c\u4f7f\u7528calc((100% &#8211; 40px) \/ 4)\u8fdb\u884c\u6df7\u5408\u5355\u4f4d\u8fd0\u7b97\u4f1a\u51fa\u73b0\u5f02\u5e38\uff0c\u7ed3\u679c\u4f1a\u88ab\u89e3\u6790\u4e3acalc(15%)\u3002 \u539f\u56e0\uff1a less\u5728\u89e3\u6790calc()\u65f6\u4f1a\u5ffd\u7565\u5355\u4f4d\uff0c\u5c06\u6240\u6709\u8fd0\u7b97\u7b26\u90fd\u6309\u7167\u767e\u5206\u6bd4\u8ba1\u7b97\u3002\u56e0\u6b64\uff0c(100% &#8211; 40px)\u4f1a\u88ab\u89e3\u6790\u4e3a(100% &#8211; 40\/100%)\uff0c\u5373(100% &#8211; 40%) = 60%\u3002\u800c60% \/ 4 = 15%\uff0c\u6240\u4ee5\u7ed3\u679c\u4e3acalc(15%)\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u6709\u4e24\u79cd\u89e3\u51b3\u65b9\u6cd5\uff1a \u4f7f\u7528\u6ce2\u6d6a\u53f7(~)\u6307\u5b9a\u53d8\u91cf\uff0c\u5982calc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\u3002\u6ce2\u6d6a\u53f7\u544a\u8bc9less\u5c06\u53d8\u91cf\u89e3\u6790\u4e3a\u503c\uff0c\u800c\u4e0d\u662f\u5355\u4f4d\u3002 \u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\u6765\u5b58\u50a8\u5355\u4f4d\uff0c\u5982@myHeight: 30px\uff0c\u7136\u540e\u4f7f\u7528calc((~&#8221;100% &#8211; @{myHeight}&#8221;) \/ 4)\u3002 \u4ee5\u4e0a\u5c31\u662fLess \u4e2d calc() \u51fd\u6570\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u6df7\u5408\u5355\u4f4d\u8ba1\u7b97\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-1665","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1665","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=1665"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1665\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}