{"id":3559,"date":"2024-11-10T10:47:24","date_gmt":"2024-11-10T02:47:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3559\/"},"modified":"2024-11-10T10:47:24","modified_gmt":"2024-11-10T02:47:24","slug":"less-%e4%b8%ad-calc-%e8%bf%90%e7%ae%97%e5%8d%95%e4%bd%8d%e6%b7%b7%e5%90%88%e9%99%b7%e9%98%b1%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88-100-40px-4-%e7%bb%93%e6%9e%9c%e4%bc%9a%e5%8f%98%e6%88%90-15","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3559\/","title":{"rendered":"LESS \u4e2d calc() \u8fd0\u7b97\u5355\u4f4d\u6df7\u5408\u9677\u9631\uff1a\u4e3a\u4ec0\u4e48 (100% &#8211; 40px) \/ 4 \u7ed3\u679c\u4f1a\u53d8\u6210 15%\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173105821230967.jpg\" class=\"aligncenter\" title=\"LESS \u4e2d calc() \u8fd0\u7b97\u5355\u4f4d\u6df7\u5408\u9677\u9631\uff1a\u4e3a\u4ec0\u4e48 (100% &#8211; 40px) \/ 4 \u7ed3\u679c\u4f1a\u53d8\u6210 15%\uff1f\u63d2\u56fe\" alt=\"LESS \u4e2d calc() \u8fd0\u7b97\u5355\u4f4d\u6df7\u5408\u9677\u9631\uff1a\u4e3a\u4ec0\u4e48 (100% &#8211; 40px) \/ 4 \u7ed3\u679c\u4f1a\u53d8\u6210 15%\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>less \u4e2d\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u7684\u9677\u9631\uff1a calc((100% &#8211; 40px) \/ 4) \u8ba1\u7b97\u7ed3\u679c\u504f\u5dee\uff1f<\/strong><\/p>\n<p>\u5728 LESS \u4e2d\u4f7f\u7528\u5e26\u5355\u4f4d\u6df7\u5408\u7684 calc() \u8fd0\u7b97\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230 unexpected \u7684\u7ed3\u679c\u3002\u672c\u6587\u5c06\u63a2\u7a76\u4e3a\u4ec0\u4e48 calc((100% &#8211; 40px) \/ 4) \u5728\u7279\u5b9a\u73af\u5883\u4e0b\u4f1a\u8ba1\u7b97\u4e3a calc(15%)\uff0c\u5e76\u63d0\u4f9b\u4fee\u590d\u65b9\u6cd5\u3002<\/p>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u201c<\/p>\n<p>\u6b63\u5f0f\u73af\u5883\u662f\u6b63\u5e38\u7684\uff0c\u4f46\u662f\u6d4b\u8bd5\u73af\u5883\u603b\u4f1a\u8ba1\u7b97\u4e3a15%<\/p>\n<p>\u201d <\/p>\n<p><strong>\u7b54\u6848<\/strong><\/p>\n<p>\u5728 LESS \u4e2d\uff0ccalc(100% &#8211; 40px) \u7b49\u5e26\u6709\u6df7\u5408\u5355\u4f4d\u7684\u8fd0\u7b97\u4f1a\u88ab\u89e3\u6790\u5668\u5ffd\u7565\u5355\u4f4d\uff0c\u5168\u90e8\u6309\u7167\u767e\u5206\u6bd4\u8ba1\u7b97\u3002\u56e0\u6b64\uff0ccalc(100% &#8211; 40px) = 60%\uff0c\u800c 60% \/ 4 = 15%\uff0c\u5373 calc(100% &#8211; 40px) \/ 4 \u88ab\u89e3\u6790\u4e3a calc(15%)\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u907f\u514d\u6b64\u95ee\u9898\uff1a<\/p>\n<ul>\n<li>\u76f4\u63a5\u4f7f\u7528\uff1acalc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\uff0c\u5176\u4e2d ~ \u7b26\u53f7\u5f3a\u5236\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u89e3\u6790\uff1b<\/li>\n<li>\u5b9a\u4e49\u53d8\u91cf\uff1a@myHeight: 30px\uff0c\u7136\u540e calc((~&#8221;100% &#8211; @{myHeight}&#8221;) \/ 4)\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u8fd9\u6837\u505a\uff0cLESS \u89e3\u6790\u5668\u5c06\u6b63\u786e\u5730\u4fdd\u7559\u5355\u4f4d\uff0c\u9632\u6b62\u610f\u5916\u7684\u8ba1\u7b97\u7ed3\u679c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLESS \u4e2d calc() \u8fd0\u7b97\u5355\u4f4d\u6df7\u5408\u9677\u9631\uff1a (100% &#8211; 40px) \/ 4 \u7ed3\u679c\u4f1a\u53d8\u6210 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 \u4e2d\u5355\u4f4d\u6df7\u5408\u8fd0\u7b97\u7684\u9677\u9631\uff1a calc((100% &#8211; 40px) \/ 4) \u8ba1\u7b97\u7ed3\u679c\u504f\u5dee\uff1f \u5728 LESS \u4e2d\u4f7f\u7528\u5e26\u5355\u4f4d\u6df7\u5408\u7684 calc() \u8fd0\u7b97\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230 unexpected \u7684\u7ed3\u679c\u3002\u672c\u6587\u5c06\u63a2\u7a76\u4e3a\u4ec0\u4e48 calc((100% &#8211; 40px) \/ 4) \u5728\u7279\u5b9a\u73af\u5883\u4e0b\u4f1a\u8ba1\u7b97\u4e3a calc(15%)\uff0c\u5e76\u63d0\u4f9b\u4fee\u590d\u65b9\u6cd5\u3002 \u95ee\u9898 \u201c \u6b63\u5f0f\u73af\u5883\u662f\u6b63\u5e38\u7684\uff0c\u4f46\u662f\u6d4b\u8bd5\u73af\u5883\u603b\u4f1a\u8ba1\u7b97\u4e3a15% \u201d \u7b54\u6848 \u5728 LESS \u4e2d\uff0ccalc(100% &#8211; 40px) \u7b49\u5e26\u6709\u6df7\u5408\u5355\u4f4d\u7684\u8fd0\u7b97\u4f1a\u88ab\u89e3\u6790\u5668\u5ffd\u7565\u5355\u4f4d\uff0c\u5168\u90e8\u6309\u7167\u767e\u5206\u6bd4\u8ba1\u7b97\u3002\u56e0\u6b64\uff0ccalc(100% &#8211; 40px) = 60%\uff0c\u800c 60% \/ 4 = 15%\uff0c\u5373 calc(100% &#8211; 40px) \/ 4 \u88ab\u89e3\u6790\u4e3a calc(15%)\u3002 \u89e3\u51b3\u65b9\u6848 \u6709\u4e24\u79cd\u65b9\u6cd5\u53ef\u4ee5\u907f\u514d\u6b64\u95ee\u9898\uff1a \u76f4\u63a5\u4f7f\u7528\uff1acalc((~&#8221;100% &#8211; 40px&#8221;) \/ [&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-3559","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3559","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=3559"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3559\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}