{"id":25887,"date":"2024-11-24T09:19:33","date_gmt":"2024-11-24T01:19:33","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25887\/"},"modified":"2024-11-24T09:19:33","modified_gmt":"2024-11-24T01:19:33","slug":"%e5%a6%82%e4%bd%95%e8%87%aa%e5%ae%9a%e4%b9%89-details-%e5%92%8c-summary-%e5%85%83%e7%b4%a0%e7%9a%84%e7%82%b9%e5%87%bb%e8%8c%83%e5%9b%b4%ef%bc%8c%e4%bb%85%e5%af%b9%e5%9b%be%e6%a0%87%e8%b5%b7%e4%bd%9c-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25887\/","title":{"rendered":"\u5982\u4f55\u81ea\u5b9a\u4e49 details \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4\uff0c\u4ec5\u5bf9\u56fe\u6807\u8d77\u4f5c\u7528\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173072162538715.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u81ea\u5b9a\u4e49 details \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4\uff0c\u4ec5\u5bf9\u56fe\u6807\u8d77\u4f5c\u7528\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u81ea\u5b9a\u4e49 details \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4\uff0c\u4ec5\u5bf9\u56fe\u6807\u8d77\u4f5c\u7528\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5b9a\u5236 detls \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4<\/strong><\/p>\n<p>\u672c\u6587\u65e8\u5728\u89e3\u51b3\u5982\u4f55\u81ea\u5b9a\u4e49 details \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4\uff0c\u4f7f\u5176\u53ea\u5bf9\u7279\u5b9a\u533a\u57df\u8d77\u4f5c\u7528\u3002<\/p>\n<p><strong>\u95ee\u9898\u63cf\u8ff0<\/strong><\/p>\n<p>\u4e00\u4f4d\u7528\u6237\u60f3\u8981\u521b\u5efa\u4e00\u4e2a\u7c7b\u4f3c\u6811\u5f62\u7ed3\u6784\u7684\u8868\u683c\uff0c\u5176\u4e2d details \u548c summary \u5143\u7d20\u7528\u4e8e\u5c55\u5f00\u548c\u5173\u95ed\u5185\u5bb9\u3002\u4f46\u662f\uff0c\u5f53\u524d\u70b9\u51fb\u8be5\u884c\u7684\u4efb\u4f55\u4f4d\u7f6e\u90fd\u4f1a\u89e6\u53d1\u5c55\u5f00\u6216\u5173\u95ed\u52a8\u4f5c\uff0c\u800c\u7528\u6237\u5e0c\u671b\u4ec5\u5728\u70b9\u51fb\u884c\u6700\u524d\u9762\u7684\u56fe\u6807\u65f6\u89e6\u53d1\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<ol>\n<li> <strong>\u6dfb\u52a0\u989d\u5916 span \u5143\u7d20<\/strong>\uff1a\u5728 summary \u5143\u7d20\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5d4c\u5957\u7684 span \u5143\u7d20\u3002<\/li>\n<li> <strong>\u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a<\/strong>\uff1a\u5728\u5b50 span \u5143\u7d20\u4e0a\u6dfb\u52a0 \uff0c\u5c06\u5176 display \u5c5e\u6027\u8bbe\u7f6e\u4e3a inline-block\uff0c\u5e76\u963b\u6b62\u5176\u9ed8\u8ba4\u963b\u6b62\u3002<\/li>\n<li> <strong>\u589e\u52a0\u56fe\u6807\u5c42\u7ea7<\/strong>\uff1a\u5728 summary \u5143\u7d20\u7684 before \u4f2a\u5143\u7d20\u4e0a\u589e\u52a0 css\uff0c\u4f7f\u5176 z-index \u503c\u5927\u4e8e\u5b50 span \u5143\u7d20\uff0c\u786e\u4fdd\u56fe\u6807\u59cb\u7ec8\u5728\u5b50 span \u5143\u7d20\u4e4b\u4e0a\u3002<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801\u793a\u4f8b<\/strong><\/p>\n<p>css\uff1a<\/p>\n<pre>.tree summary::before {\n  position: relative;\n  z-index: 2;\n  cursor: pointer\n}\n\n.tree summary span::before {\n  content: '';\n  position: absolute;\n  left: 0;\n  right: 0;\n  height: 46px;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>javascript\uff1a<\/p>\n<pre>tree.addEventListener('click', function(ev) {\n  if (ev.target.tagName === 'SPAN') {\n    ev.preventDefault()\n  }\n})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u70b9\u51fb\u884c\u6700\u524d\u9762\u7684\u56fe\u6807\u5c06\u89e6\u53d1\u5c55\u5f00\u6216\u5173\u95ed\u52a8\u4f5c\uff0c\u800c\u4e0d\u53d7\u884c\u4e2d\u5176\u4ed6\u533a\u57df\u7684\u5f71\u54cd\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u81ea\u5b9a\u4e49 detls \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4\uff0c\u4ec5\u5bf9\u56fe\u6807\u8d77\u4f5c\u7528\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>\u5b9a\u5236 detls \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4 \u672c\u6587\u65e8\u5728\u89e3\u51b3\u5982\u4f55\u81ea\u5b9a\u4e49 details \u548c summary \u5143\u7d20\u7684\u70b9\u51fb\u8303\u56f4\uff0c\u4f7f\u5176\u53ea\u5bf9\u7279\u5b9a\u533a\u57df\u8d77\u4f5c\u7528\u3002 \u95ee\u9898\u63cf\u8ff0 \u4e00\u4f4d\u7528\u6237\u60f3\u8981\u521b\u5efa\u4e00\u4e2a\u7c7b\u4f3c\u6811\u5f62\u7ed3\u6784\u7684\u8868\u683c\uff0c\u5176\u4e2d details \u548c summary \u5143\u7d20\u7528\u4e8e\u5c55\u5f00\u548c\u5173\u95ed\u5185\u5bb9\u3002\u4f46\u662f\uff0c\u5f53\u524d\u70b9\u51fb\u8be5\u884c\u7684\u4efb\u4f55\u4f4d\u7f6e\u90fd\u4f1a\u89e6\u53d1\u5c55\u5f00\u6216\u5173\u95ed\u52a8\u4f5c\uff0c\u800c\u7528\u6237\u5e0c\u671b\u4ec5\u5728\u70b9\u51fb\u884c\u6700\u524d\u9762\u7684\u56fe\u6807\u65f6\u89e6\u53d1\u3002 \u89e3\u51b3\u65b9\u6848 \u6dfb\u52a0\u989d\u5916 span \u5143\u7d20\uff1a\u5728 summary \u5143\u7d20\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5d4c\u5957\u7684 span \u5143\u7d20\u3002 \u963b\u6b62\u9ed8\u8ba4\u884c\u4e3a\uff1a\u5728\u5b50 span \u5143\u7d20\u4e0a\u6dfb\u52a0 \uff0c\u5c06\u5176 display \u5c5e\u6027\u8bbe\u7f6e\u4e3a inline-block\uff0c\u5e76\u963b\u6b62\u5176\u9ed8\u8ba4\u963b\u6b62\u3002 \u589e\u52a0\u56fe\u6807\u5c42\u7ea7\uff1a\u5728 summary \u5143\u7d20\u7684 before \u4f2a\u5143\u7d20\u4e0a\u589e\u52a0 css\uff0c\u4f7f\u5176 z-index \u503c\u5927\u4e8e\u5b50 span \u5143\u7d20\uff0c\u786e\u4fdd\u56fe\u6807\u59cb\u7ec8\u5728\u5b50 span \u5143\u7d20\u4e4b\u4e0a\u3002 \u4ee3\u7801\u793a\u4f8b css\uff1a .tree summary::before { position: relative; z-index: 2; cursor: pointer } [&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-25887","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25887","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=25887"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25887\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}