{"id":1870,"date":"2024-11-10T12:38:20","date_gmt":"2024-11-10T04:38:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1870\/"},"modified":"2024-11-10T12:38:20","modified_gmt":"2024-11-10T04:38:20","slug":"less%e4%b8%adcalc%e5%87%bd%e6%95%b0%e5%8d%95%e4%bd%8d%e6%b7%b7%e5%90%88%e8%bf%90%e7%ae%97%e9%97%ae%e9%a2%98%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88100-40px-4-15%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1870\/","title":{"rendered":"LESS\u4e2dcalc()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48100% &#8211; 40px \/ 4 = 15%\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173060821385027.jpg\" class=\"aligncenter\" title=\"LESS\u4e2dcalc()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48100% &#8211; 40px \/ 4 = 15%\uff1f\u63d2\u56fe\" alt=\"LESS\u4e2dcalc()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48100% &#8211; 40px \/ 4 = 15%\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>LESS\u4e2dcalc()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\u63a2\u8ba8<\/strong><\/p>\n<p>\u5728\u4f7f\u7528LESS\u5f00\u53d1\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230calc()\u51fd\u6570\u4e2d\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u8ba1\u7b97\u7ed3\u679c\u4e0e\u9884\u671f\u4e0d\u7b26\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5982\u95ee\u9898\u4e2d\u6240\u8ff0\uff0c\u8868\u8fbe\u5f0fcalc((100% &#8211; 40px) \/ 4)\u5728\u5b9e\u9645\u73af\u5883\u4e2d\u8ba1\u7b97\u6b63\u5e38\uff0c\u800c\u5728\u6d4b\u8bd5\u73af\u5883\u4e2d\u5374\u8fd4\u56decalc(15%)\u3002<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8eLESS\u89e3\u6790\u673a\u5236\u3002\u5728\u5e26\u5355\u4f4d\u7684\u6df7\u5408\u8fd0\u7b97\u4e2d\uff0cLESS\u4f1a\u5ffd\u7565\u5355\u4f4d\uff0c\u5c06\u6240\u6709\u503c\u6309\u767e\u5206\u6bd4\u8ba1\u7b97\u3002\u56e0\u6b64\uff0c\u4e0a\u9762\u7684\u8868\u8fbe\u5f0f\u88ab\u89e3\u6790\u4e3acalc(60%\/4)=calc(15%)\u3002<\/p>\n<p>\u89e3\u51b3\u6b64\u95ee\u9898\u7684\u4e24\u79cd\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\u4f7f\u7528\u5355\u4f4d\u7b26\u53f7\u5305\u88f9\u8868\u8fbe\u5f0f\uff1acalc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\u3002<\/li>\n<li>\u5b9a\u4e49\u53d8\u91cf\u5b58\u50a8\u5355\u4f4d\u503c\uff0c\u5e76\u5c06\u5176\u4f5c\u4e3a\u767e\u5206\u6bd4\u53c2\u4e0e\u8ba1\u7b97\uff1a@myHeight: 30px; calc((~&#8221;100% &#8211; @{myHeight}&#8221;) \/ 4)\u3002<\/li>\n<\/ol>\n<p>\u8fd9\u6837\uff0cLESS\u5c31\u53ef\u4ee5\u6b63\u786e\u8bc6\u522b\u5355\u4f4d\uff0c\u786e\u4fdd\u8ba1\u7b97\u7ed3\u679c\u7b26\u5408\u9884\u671f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLESS\u4e2dcalc()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48100% &#8211; 40px \/ 4 = 15%\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()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\u63a2\u8ba8 \u5728\u4f7f\u7528LESS\u5f00\u53d1\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230calc()\u51fd\u6570\u4e2d\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u8ba1\u7b97\u7ed3\u679c\u4e0e\u9884\u671f\u4e0d\u7b26\u7684\u60c5\u51b5\u3002 \u5982\u95ee\u9898\u4e2d\u6240\u8ff0\uff0c\u8868\u8fbe\u5f0fcalc((100% &#8211; 40px) \/ 4)\u5728\u5b9e\u9645\u73af\u5883\u4e2d\u8ba1\u7b97\u6b63\u5e38\uff0c\u800c\u5728\u6d4b\u8bd5\u73af\u5883\u4e2d\u5374\u8fd4\u56decalc(15%)\u3002 \u8fd9\u4e2a\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8eLESS\u89e3\u6790\u673a\u5236\u3002\u5728\u5e26\u5355\u4f4d\u7684\u6df7\u5408\u8fd0\u7b97\u4e2d\uff0cLESS\u4f1a\u5ffd\u7565\u5355\u4f4d\uff0c\u5c06\u6240\u6709\u503c\u6309\u767e\u5206\u6bd4\u8ba1\u7b97\u3002\u56e0\u6b64\uff0c\u4e0a\u9762\u7684\u8868\u8fbe\u5f0f\u88ab\u89e3\u6790\u4e3acalc(60%\/4)=calc(15%)\u3002 \u89e3\u51b3\u6b64\u95ee\u9898\u7684\u4e24\u79cd\u65b9\u6cd5\uff1a \u4f7f\u7528\u5355\u4f4d\u7b26\u53f7\u5305\u88f9\u8868\u8fbe\u5f0f\uff1acalc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\u3002 \u5b9a\u4e49\u53d8\u91cf\u5b58\u50a8\u5355\u4f4d\u503c\uff0c\u5e76\u5c06\u5176\u4f5c\u4e3a\u767e\u5206\u6bd4\u53c2\u4e0e\u8ba1\u7b97\uff1a@myHeight: 30px; calc((~&#8221;100% &#8211; @{myHeight}&#8221;) \/ 4)\u3002 \u8fd9\u6837\uff0cLESS\u5c31\u53ef\u4ee5\u6b63\u786e\u8bc6\u522b\u5355\u4f4d\uff0c\u786e\u4fdd\u8ba1\u7b97\u7ed3\u679c\u7b26\u5408\u9884\u671f\u3002 \u4ee5\u4e0a\u5c31\u662fLESS\u4e2dcalc()\u51fd\u6570\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u95ee\u9898\uff1a\u4e3a\u4ec0\u4e48100% &#8211; 40px \/ 4 = 15%\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-1870","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1870","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=1870"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1870\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}