{"id":2210,"date":"2024-11-10T08:17:02","date_gmt":"2024-11-10T00:17:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/2210\/"},"modified":"2024-11-10T08:17:02","modified_gmt":"2024-11-10T00:17:02","slug":"%e5%a6%82%e4%bd%95%e7%94%a8-css-%e5%ae%9e%e7%8e%b0%e6%96%87%e5%ad%97%e4%b8%a4%e8%be%b9%e5%8a%a0%e4%b8%ad%e5%88%92%e7%ba%bf%e6%95%88%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/2210\/","title":{"rendered":"\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u52a0\u4e2d\u5212\u7ebf\u6548\u679c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173069089574030.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u52a0\u4e2d\u5212\u7ebf\u6548\u679c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u52a0\u4e2d\u5212\u7ebf\u6548\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u4e2d\u5212\u7ebf\u7684\u6548\u679c\uff1f<\/strong><\/p>\n<p>\u4e3a\u4e86\u5728\u6587\u5b57\u7684\u4e24\u8fb9\u6dfb\u52a0\u7ea2\u6846\u4e2d\u6240\u793a\u7684\u4e2d\u5212\u7ebf\uff0c\u53ef\u4ee5\u5229\u7528  \u4e2d\u7684 <strong>::before<\/strong> \u548c <strong>::after<\/strong> \u4f2a\u5143\u7d20\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\u5c06\u6587\u672c\u5143\u7d20\uff08\u5982\n<p>\uff09\u8bbe\u7f6e\u4e3a flex \u5e03\u5c40\uff0c\u6587\u672c\u5c45\u4e2d\u5bf9\u9f50\u3002<\/p>\n<\/li>\n<li>\u4f7f\u7528 <strong>::before<\/strong> \u4f2a\u5143\u7d20\u5728\u6587\u5b57\u524d\u6dfb\u52a0\u4e00\u4e2a\u7ea2\u7ebf\uff0c\u8bbe\u7f6e flex \u5c5e\u6027\u4e3a 1 \u4ee5\u5360\u636e\u53ef\u7528\u7684\u5269\u4f59\u7a7a\u95f4\uff0c\u5e76\u5411\u53f3\u7559\u51fa\u4e00\u5b9a\u7684\u8fb9\u8ddd\u3002<\/li>\n<li>\u4f7f\u7528 <strong>::after<\/strong> \u4f2a\u5143\u7d20\u5728\u6587\u5b57\u540e\u6dfb\u52a0\u53e6\u4e00\u4e2a\u7ea2\u7ebf\uff0c\u540c\u6837\u8bbe\u7f6e flex \u5c5e\u6027\u4e3a 1 \u5e76\u5411\u5de6\u7559\u51fa\u8fb9\u8ddd\u3002<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801\u793a\u4f8b\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n    &lt;head&gt;\n        &lt;meta charset=\"UTF-8\" \/&gt;\n        &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n        &lt;title&gt;Document&lt;\/title&gt;\n        &lt;style&gt;\n            * {\n                margin: 0;\n                padding: 0;\n            }\n            .text {\n                display: flex;\n                align-items: center;\n                justify-content: center;\n            }\n            .text::before {\n                content: \"\";\n                flex: 1;\n                background-color: red;\n                height: 1px;\n                margin-right: 10px;\n            }\n            .text::after {\n                content: \"\";\n                flex: 1;\n                background-color: red;\n                height: 1px;\n                margin-left: 10px;\n            }\n        &lt;\/style&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;div class=\"text\"&gt;\u4e00\u6bb5\u6587\u5b57&lt;\/div&gt;\n    &lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5b9e\u73b0\u7ea2\u6846\u4e2d\u6240\u793a\u7684\u6587\u5b57\u4e24\u8fb9\u4e2d\u5212\u7ebf\u6548\u679c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528 CSS \u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u52a0\u4e2d\u5212\u7ebf\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>\u5982\u4f55\u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u4e2d\u5212\u7ebf\u7684\u6548\u679c\uff1f \u4e3a\u4e86\u5728\u6587\u5b57\u7684\u4e24\u8fb9\u6dfb\u52a0\u7ea2\u6846\u4e2d\u6240\u793a\u7684\u4e2d\u5212\u7ebf\uff0c\u53ef\u4ee5\u5229\u7528 \u4e2d\u7684 ::before \u548c ::after \u4f2a\u5143\u7d20\u3002 \u6b65\u9aa4\uff1a \u5c06\u6587\u672c\u5143\u7d20\uff08\u5982 \uff09\u8bbe\u7f6e\u4e3a flex \u5e03\u5c40\uff0c\u6587\u672c\u5c45\u4e2d\u5bf9\u9f50\u3002 \u4f7f\u7528 ::before \u4f2a\u5143\u7d20\u5728\u6587\u5b57\u524d\u6dfb\u52a0\u4e00\u4e2a\u7ea2\u7ebf\uff0c\u8bbe\u7f6e flex \u5c5e\u6027\u4e3a 1 \u4ee5\u5360\u636e\u53ef\u7528\u7684\u5269\u4f59\u7a7a\u95f4\uff0c\u5e76\u5411\u53f3\u7559\u51fa\u4e00\u5b9a\u7684\u8fb9\u8ddd\u3002 \u4f7f\u7528 ::after \u4f2a\u5143\u7d20\u5728\u6587\u5b57\u540e\u6dfb\u52a0\u53e6\u4e00\u4e2a\u7ea2\u7ebf\uff0c\u540c\u6837\u8bbe\u7f6e flex \u5c5e\u6027\u4e3a 1 \u5e76\u5411\u5de6\u7559\u51fa\u8fb9\u8ddd\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b &lt;!DOCTYPE html&gt; &lt;html lang=&#8221;en&#8221;&gt; &lt;head&gt; &lt;meta charset=&#8221;UTF-8&#8243; \/&gt; &lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1.0&#8243; \/&gt; &lt;title&gt;Document&lt;\/title&gt; &lt;style&gt; * { margin: 0; padding: 0; } .text { display: flex; align-items: [&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-2210","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2210","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=2210"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/2210\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=2210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=2210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=2210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}