{"id":25914,"date":"2024-11-24T14:47:29","date_gmt":"2024-11-24T06:47:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25914\/"},"modified":"2024-11-24T14:47:29","modified_gmt":"2024-11-24T06:47:29","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-css-%e5%ae%9e%e7%8e%b0-%e6%a0%87%e7%ad%be%e5%86%85%e6%96%87%e5%ad%97%e4%b8%a4%e8%be%b9%e4%b8%ad%e9%97%b4%e5%b8%a6%e6%9c%89%e6%a8%aa%e7%ba%bf%e7%9a%84%e6%a0%b7-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25914\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0 &#8220; \u6807\u7b7e\u5185\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u5e26\u6709\u6a2a\u7ebf\u7684\u6837\u5f0f\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173072539895896.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0 &#8220; \u6807\u7b7e\u5185\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u5e26\u6709\u6a2a\u7ebf\u7684\u6837\u5f0f\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0 &#8220; \u6807\u7b7e\u5185\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u5e26\u6709\u6a2a\u7ebf\u7684\u6837\u5f0f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5b9e\u73b0\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u6a2a\u7ebf\u7684  \u6837\u5f0f<\/strong><\/p>\n<p>\u95ee\u9898\uff1a<br \/>\u5982\u4f55\u4f7f\u7528 css \u5b9e\u73b0<\/p>\n<p>\u6807\u7b7e\u5185\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u5e26\u6709\u6a2a\u7ebf\u7684\u6837\u5f0f\uff1f<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<br \/>\u4f7f\u7528 ::before \u548c ::after \u4f2a\u5143\u7d20\uff0c\u4ee5\u53ca flex \u5e03\u5c40\u548c content \u5c5e\u6027\u3002<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b\uff1a<\/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>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff1a<\/p>\n<ul>\n<li>* \u6837\u5f0f\u9009\u62e9\u6240\u6709\u5143\u7d20\uff0c\u5e76\u91cd\u7f6e\u5b83\u4eec\u7684\u8fb9\u8ddd\u548c\u5185\u8fb9\u8ddd\u3002<\/li>\n<li>.text \u7c7b\u6837\u5f0f\u5c06\u6587\u672c\u5143\u7d20\u8bbe\u7f6e\u4e3a\u6c34\u5e73\u5c45\u4e2d\uff0c\u4e14\u5782\u76f4\u5bf9\u9f50\u7ebf\u4e3a\u4e2d\u95f4\u3002<\/li>\n<li>::before \u4f2a\u5143\u7d20\u5728\u5143\u7d20\u4e4b\u524d\u521b\u5efa\u4e00\u4e2a\u5757\u72b6\u76d2\u5b50\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6e\u7ea2\u8272\u80cc\u666f\u548c\u5bbd\u5ea6\u4e3a 1px \u7684\u6a2a\u7ebf\u3002<\/li>\n<li>::after \u4f2a\u5143\u7d20\u5728\u5143\u7d20\u4e4b\u540e\u521b\u5efa\u4e00\u4e2a\u5757\u72b6\u76d2\u5b50\uff0c\u5e76\u4e3a\u5176\u8bbe\u7f6e\u7ea2\u8272\u80cc\u666f\u548c\u5bbd\u5ea6\u4e3a 1px \u7684\u6a2a\u7ebf\u3002<\/li>\n<li>margin \u5c5e\u6027\u7528\u4e8e\u8c03\u6574\u6c34\u5e73\u7ebf\u4e0e\u6587\u672c\u4e4b\u95f4\u7684\u95f4\u8ddd\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CSS \u5b9e\u73b0 &#8220; \u6807\u7b7e\u5185\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u5e26\u6709\u6a2a\u7ebf\u7684\u6837\u5f0f\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\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u6a2a\u7ebf\u7684 \u6837\u5f0f \u95ee\u9898\uff1a\u5982\u4f55\u4f7f\u7528 css \u5b9e\u73b0 \u6807\u7b7e\u5185\u6587\u5b57\u4e24\u8fb9\u4e2d\u95f4\u5e26\u6709\u6a2a\u7ebf\u7684\u6837\u5f0f\uff1f \u89e3\u51b3\u65b9\u6848\uff1a\u4f7f\u7528 ::before \u548c ::after \u4f2a\u5143\u7d20\uff0c\u4ee5\u53ca flex \u5e03\u5c40\u548c content \u5c5e\u6027\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: center; justify-content: center; } .text::before { content: &#8220;&#8221;; flex: 1; background-color: [&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-25914","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25914","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=25914"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25914\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}