{"id":26520,"date":"2024-11-24T08:36:04","date_gmt":"2024-11-24T00:36:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26520\/"},"modified":"2024-11-24T08:36:04","modified_gmt":"2024-11-24T00:36:04","slug":"less%e4%b8%ad%e8%ae%a1%e7%ae%97%e5%8d%95%e4%bd%8d%e6%b7%b7%e5%90%88%e8%a1%a8%e8%be%be%e5%bc%8f%e4%b8%ba%e4%bd%95%e4%bc%9a%e5%87%ba%e7%8e%b0%e5%81%8f%e5%b7%ae%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26520\/","title":{"rendered":"Less\u4e2d\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u4e3a\u4f55\u4f1a\u51fa\u73b0\u504f\u5dee\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173097326345769.jpg\" class=\"aligncenter\" title=\"Less\u4e2d\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u4e3a\u4f55\u4f1a\u51fa\u73b0\u504f\u5dee\uff1f\u63d2\u56fe\" alt=\"Less\u4e2d\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u4e3a\u4f55\u4f1a\u51fa\u73b0\u504f\u5dee\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>less\u4e2d\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u7684\u7591\u60d1<\/strong><\/p>\n<p>\u5728Less\u4e2d\uff0c\u4f7f\u7528calc()\u51fd\u6570\u5bf9\u5e26\u6709\u4e0d\u540c\u5355\u4f4d\u7684\u8868\u8fbe\u5f0f\u8fdb\u884c\u8ba1\u7b97\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u610f\u6599\u4e4b\u5916\u7684\u7ed3\u679c\u3002\u4f8b\u5982\uff1acalc((100% &#8211; 40px) \/ 4)\u672c\u6765\u5e94\u8be5\u5f97\u523020%\uff0c\u4f46\u662f\u5728\u67d0\u4e9b\u73af\u5883\u4e0b\u5374\u53d8\u4e3a\u4e8615%\u3002<\/p>\n<p><strong>\u95ee\u9898\u6839\u6e90<\/strong><\/p>\n<p>\u8fd9\u79cd\u5dee\u5f02\u6e90\u4e8eLess\u5bf9\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u7684\u5904\u7406\u65b9\u5f0f\u3002\u5f53less\u89e3\u6790calc()\u51fd\u6570\u4e2d\u7684\u8868\u8fbe\u5f0f\u65f6\uff0c\u5b83\u4f1a\u5ffd\u7565\u5355\u4f4d\uff0c\u5e76\u6309\u7167\u767e\u5206\u6bd4\u8fdb\u884c\u8ba1\u7b97\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c100%\u88ab\u8ba4\u4e3a\u662f100\u4e2a\u767e\u5206\u70b9\uff0c\u800c40px\u5219\u88ab\u5ffd\u7565\u3002\u56e0\u6b64\uff0ccalc((100% &#8211; 40px) \/ 4)\u88ab\u89e3\u6790\u4e3acalc((100 &#8211; 0) \/ 4)\uff0c\u5373calc(100 \/ 4) = calc(15%)\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u6b64\u95ee\u9898\uff0c\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li><strong>\u4f7f\u7528\u5355\u4f4d\u8f6c\u6362\u51fd\u6570<\/strong><\/li>\n<\/ol>\n<p>\u53ef\u4ee5\u5728\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528Less\u63d0\u4f9b\u7684~&#8221;()&#8221;\u51fd\u6570\u5c06\u50cf\u7d20\u5355\u4f4d\u8f6c\u6362\u4e3a\u767e\u5206\u6bd4\u3002\u4f8b\u5982\uff1acalc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\u3002<\/p>\n<ol>\n<li><strong>\u5b9a\u4e49\u5c40\u90e8\u53d8\u91cf<\/strong><\/li>\n<\/ol>\n<p>\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u5c40\u90e8\u53d8\u91cf\u6765\u5b58\u50a8\u50cf\u7d20\u503c\uff0c\u7136\u540e\u5728\u8ba1\u7b97\u4e2d\u4f7f\u7528\u53d8\u91cf\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>@myHeight: 30px;\ncalc((~\"100% - @{myHeight}\") \/ 4);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fLess\u4e2d\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u4e3a\u4f55\u4f1a\u51fa\u73b0\u504f\u5dee\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\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u7684\u7591\u60d1 \u5728Less\u4e2d\uff0c\u4f7f\u7528calc()\u51fd\u6570\u5bf9\u5e26\u6709\u4e0d\u540c\u5355\u4f4d\u7684\u8868\u8fbe\u5f0f\u8fdb\u884c\u8ba1\u7b97\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u610f\u6599\u4e4b\u5916\u7684\u7ed3\u679c\u3002\u4f8b\u5982\uff1acalc((100% &#8211; 40px) \/ 4)\u672c\u6765\u5e94\u8be5\u5f97\u523020%\uff0c\u4f46\u662f\u5728\u67d0\u4e9b\u73af\u5883\u4e0b\u5374\u53d8\u4e3a\u4e8615%\u3002 \u95ee\u9898\u6839\u6e90 \u8fd9\u79cd\u5dee\u5f02\u6e90\u4e8eLess\u5bf9\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u7684\u5904\u7406\u65b9\u5f0f\u3002\u5f53less\u89e3\u6790calc()\u51fd\u6570\u4e2d\u7684\u8868\u8fbe\u5f0f\u65f6\uff0c\u5b83\u4f1a\u5ffd\u7565\u5355\u4f4d\uff0c\u5e76\u6309\u7167\u767e\u5206\u6bd4\u8fdb\u884c\u8ba1\u7b97\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c100%\u88ab\u8ba4\u4e3a\u662f100\u4e2a\u767e\u5206\u70b9\uff0c\u800c40px\u5219\u88ab\u5ffd\u7565\u3002\u56e0\u6b64\uff0ccalc((100% &#8211; 40px) \/ 4)\u88ab\u89e3\u6790\u4e3acalc((100 &#8211; 0) \/ 4)\uff0c\u5373calc(100 \/ 4) = calc(15%)\u3002 \u89e3\u51b3\u65b9\u6cd5 \u4e3a\u4e86\u907f\u514d\u6b64\u95ee\u9898\uff0c\u6709\u4e24\u79cd\u5e38\u89c1\u7684\u89e3\u51b3\u65b9\u6cd5\uff1a \u4f7f\u7528\u5355\u4f4d\u8f6c\u6362\u51fd\u6570 \u53ef\u4ee5\u5728\u8868\u8fbe\u5f0f\u4e2d\u4f7f\u7528Less\u63d0\u4f9b\u7684~&#8221;()&#8221;\u51fd\u6570\u5c06\u50cf\u7d20\u5355\u4f4d\u8f6c\u6362\u4e3a\u767e\u5206\u6bd4\u3002\u4f8b\u5982\uff1acalc((~&#8221;100% &#8211; 40px&#8221;) \/ 4)\u3002 \u5b9a\u4e49\u5c40\u90e8\u53d8\u91cf \u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u5c40\u90e8\u53d8\u91cf\u6765\u5b58\u50a8\u50cf\u7d20\u503c\uff0c\u7136\u540e\u5728\u8ba1\u7b97\u4e2d\u4f7f\u7528\u53d8\u91cf\u3002\u4f8b\u5982\uff1a @myHeight: 30px; calc((~&#8221;100% &#8211; @{myHeight}&#8221;) \/ 4); \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662fLess\u4e2d\u8ba1\u7b97\u5355\u4f4d\u6df7\u5408\u8868\u8fbe\u5f0f\u4e3a\u4f55\u4f1a\u51fa\u73b0\u504f\u5dee\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-26520","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26520","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=26520"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26520\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}