{"id":1391,"date":"2024-11-10T10:53:33","date_gmt":"2024-11-10T02:53:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1391\/"},"modified":"2024-11-10T10:53:33","modified_gmt":"2024-11-10T02:53:33","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-css-%e5%92%8c%e7%ae%97%e6%b3%95%e4%bc%98%e5%8c%96%e5%ae%9e%e7%8e%b0-word-%e5%bc%8f%e6%89%b9%e6%b3%a8%e9%97%b4%e8%b7%9d%e8%87%aa%e9%80%82%e5%ba%94%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1391\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 CSS \u548c\u7b97\u6cd5\u4f18\u5316\u5b9e\u73b0 Word \u5f0f\u6279\u6ce8\u95f4\u8ddd\u81ea\u9002\u5e94\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173042048698156.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 CSS \u548c\u7b97\u6cd5\u4f18\u5316\u5b9e\u73b0 Word \u5f0f\u6279\u6ce8\u95f4\u8ddd\u81ea\u9002\u5e94\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 CSS \u548c\u7b97\u6cd5\u4f18\u5316\u5b9e\u73b0 Word \u5f0f\u6279\u6ce8\u95f4\u8ddd\u81ea\u9002\u5e94\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7f51\u9875\u5b9a\u4f4d\u95ee\u9898\uff1a\u6279\u6ce8\u95f4\u8ddd\u81ea\u9002\u5e94<\/strong><\/p>\n<p>\u5728\u8bbe\u8ba1\u7c7b\u4f3c Word \u7684\u6279\u6ce8\u529f\u80fd\u65f6\uff0c\u5982\u679c\u5e0c\u671b\u5b9e\u73b0\u50cf Word \u4e2d\u4e00\u6837\u7684\u6279\u6ce8\u95f4\u8ddd\u6548\u679c\uff0c\u9700\u8981\u89e3\u51b3\u4ee5\u4e0b\u4e24\u79cd\u60c5\u51b5\u4e0b\u7684\u6279\u6ce8\u5b9a\u4f4d\u95ee\u9898\uff1a<\/p>\n<ol>\n<li><strong>\u6279\u6ce8\u95f4\u9694\u8f83\u5927\u7684\u60c5\u51b5\uff1a\u5c31\u8fd1\u539f\u5219\u663e\u793a<\/strong><\/li>\n<\/ol>\n<p>\u5bf9\u4e8e\u76f8\u8ddd\u8f83\u8fdc\u7684\u6279\u6ce8\uff0c\u5e94\u5c06\u6279\u6ce8\u5b9a\u4f4d\u5728\u9760\u8fd1\u6279\u6ce8\u6587\u672c\u7684\u4f4d\u7f6e\u3002<\/p>\n<ol>\n<li><strong>\u6279\u6ce8\u7d27\u6328\u5728\u4e00\u8d77\u7684\u60c5\u51b5\uff1a\u81ea\u9002\u5e94\u7d27\u6328\uff0c\u907f\u514d\u91cd\u53e0<\/strong><\/li>\n<\/ol>\n<p>\u5f53\u6279\u6ce8\u7d27\u6328\u5728\u4e00\u8d77\u65f6\uff0c\u9700\u8981\u81ea\u9002\u5e94\u8c03\u6574\u6279\u6ce8\u4f4d\u7f6e\uff0c\u4ee5\u907f\u514d\u76f8\u4e92\u91cd\u53e0\u3002<\/p>\n<p><strong>\u89e3\u51b3\u601d\u8def\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 CSS \u4e2d\u7684 absolute \u5b9a\u4f4d\u6765\u5b9e\u73b0\u6279\u6ce8\u7684\u5b9a\u4f4d\u3002\u7136\u540e\uff0c\u6309\u6279\u6ce8\u4ece\u4e0a\u5230\u4e0b\u7684\u987a\u5e8f\u7edf\u8ba1\u5176 top \u548c height \u503c\uff0c\u5e76\u8ba1\u7b97\u51fa\u6bcf\u4e2a\u6279\u6ce8\u7684\u6700\u5927 top \u503c\u3002<\/p>\n<p><strong>\u6570\u636e\u7ed3\u6784\uff1a<\/strong><\/p>\n<pre>[\n    {top: 100, height: 200},\n    {top: 800, height: 200},\n    {top: 820, height: 200},\n    {top: 1020, height: 200},\n]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7b97\u6cd5\u4f18\u5316\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 reduce \u65b9\u6cd5\u8ba1\u7b97\u6700\u5927 top \u503c\uff1a<\/p>\n<pre>arr.reduce((s, n, i) =&gt; {\n    n.currentTop = Math.max(n.top, (s.currentTop || s.top) + s.height)\n    return n\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>arr = [\n    {top: 100, height: 200},\n    {top: 800, height: 200},\n    {top: 820, height: 200},\n    {top: 1020, height: 200},\n    {top: 1430, height: 180},\n]\narr.reduce((s, n, i) =&gt; {\n    n.currentTop = Math.max(n.top, (s.currentTop || s.top) + s.height)\n    return n\n})\nconsole.log(arr)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<pre>[\n    {top: 100, height: 200, currentTop: 100},\n    {top: 800, height: 200, currentTop: 1000},\n    {top: 820, height: 200, currentTop: 1020},\n    {top: 1020, height: 200, currentTop: 1220},\n    {top: 1430, height: 180, currentTop: 1430}\n]<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u6279\u6ce8\u95f4\u8ddd\u7684\u81ea\u9002\u5e94\u8c03\u6574\uff0c\u89e3\u51b3\u6587\u4e2d\u63d0\u51fa\u7684\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CSS \u548c\u7b97\u6cd5\u4f18\u5316\u5b9e\u73b0 Word \u5f0f\u6279\u6ce8\u95f4\u8ddd\u81ea\u9002\u5e94\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>\u7f51\u9875\u5b9a\u4f4d\u95ee\u9898\uff1a\u6279\u6ce8\u95f4\u8ddd\u81ea\u9002\u5e94 \u5728\u8bbe\u8ba1\u7c7b\u4f3c Word \u7684\u6279\u6ce8\u529f\u80fd\u65f6\uff0c\u5982\u679c\u5e0c\u671b\u5b9e\u73b0\u50cf Word \u4e2d\u4e00\u6837\u7684\u6279\u6ce8\u95f4\u8ddd\u6548\u679c\uff0c\u9700\u8981\u89e3\u51b3\u4ee5\u4e0b\u4e24\u79cd\u60c5\u51b5\u4e0b\u7684\u6279\u6ce8\u5b9a\u4f4d\u95ee\u9898\uff1a \u6279\u6ce8\u95f4\u9694\u8f83\u5927\u7684\u60c5\u51b5\uff1a\u5c31\u8fd1\u539f\u5219\u663e\u793a \u5bf9\u4e8e\u76f8\u8ddd\u8f83\u8fdc\u7684\u6279\u6ce8\uff0c\u5e94\u5c06\u6279\u6ce8\u5b9a\u4f4d\u5728\u9760\u8fd1\u6279\u6ce8\u6587\u672c\u7684\u4f4d\u7f6e\u3002 \u6279\u6ce8\u7d27\u6328\u5728\u4e00\u8d77\u7684\u60c5\u51b5\uff1a\u81ea\u9002\u5e94\u7d27\u6328\uff0c\u907f\u514d\u91cd\u53e0 \u5f53\u6279\u6ce8\u7d27\u6328\u5728\u4e00\u8d77\u65f6\uff0c\u9700\u8981\u81ea\u9002\u5e94\u8c03\u6574\u6279\u6ce8\u4f4d\u7f6e\uff0c\u4ee5\u907f\u514d\u76f8\u4e92\u91cd\u53e0\u3002 \u89e3\u51b3\u601d\u8def\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u53ef\u4ee5\u4f7f\u7528 CSS \u4e2d\u7684 absolute \u5b9a\u4f4d\u6765\u5b9e\u73b0\u6279\u6ce8\u7684\u5b9a\u4f4d\u3002\u7136\u540e\uff0c\u6309\u6279\u6ce8\u4ece\u4e0a\u5230\u4e0b\u7684\u987a\u5e8f\u7edf\u8ba1\u5176 top \u548c height \u503c\uff0c\u5e76\u8ba1\u7b97\u51fa\u6bcf\u4e2a\u6279\u6ce8\u7684\u6700\u5927 top \u503c\u3002 \u6570\u636e\u7ed3\u6784\uff1a [ {top: 100, height: 200}, {top: 800, height: 200}, {top: 820, height: 200}, {top: 1020, height: 200}, ] \u767b\u5f55\u540e\u590d\u5236 \u7b97\u6cd5\u4f18\u5316\uff1a \u4f7f\u7528 reduce \u65b9\u6cd5\u8ba1\u7b97\u6700\u5927 top \u503c\uff1a arr.reduce((s, n, i) =&gt; { n.currentTop [&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-1391","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1391","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=1391"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1391\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}