{"id":1593,"date":"2024-11-10T11:00:50","date_gmt":"2024-11-10T03:00:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/1593\/"},"modified":"2024-11-10T11:00:50","modified_gmt":"2024-11-10T03:00:50","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e7%ba%af-css-%e5%ae%9e%e7%8e%b0%e6%af%8f%e4%b8%89%e8%a1%8c%e8%a1%a8%e6%a0%bc%e6%95%b0%e6%8d%ae%e5%91%88%e7%8e%b0%e6%96%91%e9%a9%ac%e7%ba%b9%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/1593\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528\u7eaf CSS \u5b9e\u73b0\u6bcf\u4e09\u884c\u8868\u683c\u6570\u636e\u5448\u73b0\u6591\u9a6c\u7eb9\u6548\u679c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173050903844541.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528\u7eaf CSS \u5b9e\u73b0\u6bcf\u4e09\u884c\u8868\u683c\u6570\u636e\u5448\u73b0\u6591\u9a6c\u7eb9\u6548\u679c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528\u7eaf CSS \u5b9e\u73b0\u6bcf\u4e09\u884c\u8868\u683c\u6570\u636e\u5448\u73b0\u6591\u9a6c\u7eb9\u6548\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u5b9e\u73b0\u6bcf\u4e09\u884c\u4e00\u4e2a\u6591\u9a6c\u7eb9\u8868\u683c<\/strong><\/p>\n<p>\u63d0\u51fa\u95ee\u9898\uff1a\u5728\u8fdb\u884c\u524d\u7aef\u5f00\u53d1\u65f6\uff0c\u5982\u4f55\u4f7f\u7528\u7eaf css \u5b9e\u73b0\u6bcf\u4e09\u884c\u4e00\u4e2a\u6591\u9a6c\u7eb9\u7684\u8868\u683c\u6548\u679c\uff1f<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u6b64\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 css \u4e2d\u7684 :nth-child \u9009\u62e9\u5668\u3002\u8be5\u9009\u62e9\u5668\u53ef\u7528\u4e8e\u6839\u636e\u5143\u7d20\u5728\u5144\u5f1f\u5143\u7d20\u4e2d\u7684\u4f4d\u7f6e\u8fdb\u884c\u6837\u5f0f\u5316\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b65\u9aa4\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u57fa\u7840\u6837\u5f0f<\/strong><\/li>\n<\/ol>\n<pre>.table {\n  border-collapse: collapse;\n}\n\n.table td {\n  border: 1px solid #ddd;\n}\n\n.table tr {\n  background-color: #f9f9f9;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li><strong>\u5e94\u7528\u6591\u9a6c\u7eb9\u6548\u679c<\/strong><\/li>\n<\/ol>\n<p>\u4f7f\u7528 :nth-child \u9009\u62e9\u5668\uff0c\u5c06\u9694\u884c\u7740\u8272\u3002<\/p>\n<pre>.table tr:nth-child(6n + 1),\n.table tr:nth-child(6n + 2),\n.table tr:nth-child(6n + 3) {\n  background-color: #ffffff;\n}\n\n.table tr:nth-child(6n + 4),\n.table tr:nth-child(6n + 5),\n.table tr:nth-child(6n + 6) {\n  background-color: #cccccc;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5e94\u7528\u8fd9\u4e9b\u6837\u5f0f\u540e\uff0c\u6bcf\u4e09\u884c\u8868\u683c\u6570\u636e\u5c06\u5448\u73b0\u51fa\u4ea4\u66ff\u7684\u767d\u8272\u548c\u7070\u8272\u80cc\u666f\u3002<\/p>\n<p>\u5b8c\u6574\u7684\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<pre>\/* \u8bbe\u7f6e\u57fa\u7840\u6837\u5f0f *\/\n.table {\n  border-collapse: collapse;\n}\n\n.table td {\n  border: 1px solid #ddd;\n}\n\n.table tr {\n  background-color: #f9f9f9;\n}\n\n\/* \u5e94\u7528\u6591\u9a6c\u7eb9\u6548\u679c *\/\n.table tr:nth-child(6n + 1),\n.table tr:nth-child(6n + 2),\n.table tr:nth-child(6n + 3) {\n  background-color: #ffffff;\n}\n\n.table tr:nth-child(6n + 4),\n.table tr:nth-child(6n + 5),\n.table tr:nth-child(6n + 6) {\n  background-color: #cccccc;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528\u7eaf CSS \u5b9e\u73b0\u6bcf\u4e09\u884c\u8868\u683c\u6570\u636e\u5448\u73b0\u6591\u9a6c\u7eb9\u6548\u679c\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>\u5b9e\u73b0\u6bcf\u4e09\u884c\u4e00\u4e2a\u6591\u9a6c\u7eb9\u8868\u683c \u63d0\u51fa\u95ee\u9898\uff1a\u5728\u8fdb\u884c\u524d\u7aef\u5f00\u53d1\u65f6\uff0c\u5982\u4f55\u4f7f\u7528\u7eaf css \u5b9e\u73b0\u6bcf\u4e09\u884c\u4e00\u4e2a\u6591\u9a6c\u7eb9\u7684\u8868\u683c\u6548\u679c\uff1f \u89e3\u51b3\u65b9\u6848\uff1a \u4e3a\u4e86\u5b9e\u73b0\u6b64\u6548\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 css \u4e2d\u7684 :nth-child \u9009\u62e9\u5668\u3002\u8be5\u9009\u62e9\u5668\u53ef\u7528\u4e8e\u6839\u636e\u5143\u7d20\u5728\u5144\u5f1f\u5143\u7d20\u4e2d\u7684\u4f4d\u7f6e\u8fdb\u884c\u6837\u5f0f\u5316\u3002\u4ee5\u4e0b\u662f\u5b9e\u73b0\u6b65\u9aa4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u8bbe\u7f6e\u57fa\u7840\u6837\u5f0f .table { border-collapse: collapse; } .table td { border: 1px solid #ddd; } .table tr { background-color: #f9f9f9; } \u767b\u5f55\u540e\u590d\u5236 \u5e94\u7528\u6591\u9a6c\u7eb9\u6548\u679c \u4f7f\u7528 :nth-child \u9009\u62e9\u5668\uff0c\u5c06\u9694\u884c\u7740\u8272\u3002 .table tr:nth-child(6n + 1), .table tr:nth-child(6n + 2), .table tr:nth-child(6n + 3) { background-color: #ffffff; } .table tr:nth-child(6n + [&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-1593","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1593","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=1593"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/1593\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=1593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=1593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=1593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}