{"id":47,"date":"2025-03-25T09:31:26","date_gmt":"2025-03-25T01:31:26","guid":{"rendered":"https:\/\/blog.nimail.cn\/?p=47"},"modified":"2025-03-25T09:31:26","modified_gmt":"2025-03-25T01:31:26","slug":"css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/","title":{"rendered":"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b"},"content":{"rendered":"\n<p>\u5728 CSS \u4e2d\uff0c<code>flex<\/code>&nbsp;\u548c&nbsp;<code>relative<\/code>&nbsp;\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u5e03\u5c40\u65b9\u5f0f\uff0c\u5206\u522b\u5c5e\u4e8e&nbsp;<strong>Flexbox\uff08\u5f39\u6027\u76d2\u5b50\uff09<\/strong>&nbsp;\u548c&nbsp;<strong>\u5b9a\u4f4d\uff08Positioning\uff09<\/strong>&nbsp;\u7cfb\u7edf\u3002\u5b83\u4eec\u7684\u4f5c\u7528\u548c\u7528\u6cd5\u5b8c\u5168\u4e0d\u540c\uff0c\u4e0b\u9762\u8be6\u7ec6\u89e3\u91ca\u5b83\u4eec\u7684&nbsp;<strong>\u4f7f\u7528\u65b9\u5f0f<\/strong>&nbsp;\u548c&nbsp;<strong>\u4e3b\u8981\u533a\u522b<\/strong>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1.&nbsp;<code>display: flex<\/code>\uff08\u5f39\u6027\u76d2\u5b50\u5e03\u5c40\uff09<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4f5c\u7528<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7528\u4e8e\u00a0<strong>\u5bb9\u5668\uff08\u7236\u5143\u7d20\uff09<\/strong>\uff0c\u63a7\u5236\u5176\u00a0<strong>\u5b50\u5143\u7d20\uff08flex items\uff09<\/strong>\u00a0\u7684\u6392\u5217\u65b9\u5f0f\u3002<\/li>\n\n\n\n<li>\u53ef\u4ee5\u5b9e\u73b0\u00a0<strong>\u6c34\u5e73\/\u5782\u76f4\u5bf9\u9f50\u3001\u81ea\u52a8\u5206\u914d\u7a7a\u95f4\u3001\u6362\u884c\u3001\u987a\u5e8f\u8c03\u6574<\/strong>\u00a0\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e3b\u8981\u5c5e\u6027<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u5bb9\u5668\u5c5e\u6027\uff08\u7236\u5143\u7d20\uff09<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">.container {\n  display: flex; \/* \u542f\u7528 Flexbox *\/\n  flex-direction: row | column; \/* \u4e3b\u8f74\u65b9\u5411\uff08\u884c\/\u5217\uff09 *\/\n  justify-content: center | space-between; \/* \u4e3b\u8f74\u5bf9\u9f50\u65b9\u5f0f *\/\n  align-items: center | flex-start; \/* \u4ea4\u53c9\u8f74\u5bf9\u9f50\u65b9\u5f0f *\/\n  flex-wrap: wrap | nowrap; \/* \u662f\u5426\u6362\u884c *\/\n  gap: 10px; \/* \u5b50\u5143\u7d20\u95f4\u8ddd *\/\n}<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u5b50\u5143\u7d20\u5c5e\u6027<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">.item {\n  flex-grow: 1; \/* \u5360\u636e\u5269\u4f59\u7a7a\u95f4 *\/\n  flex-shrink: 0; \/* \u662f\u5426\u5141\u8bb8\u7f29\u5c0f *\/\n  flex-basis: 100px; \/* \u521d\u59cb\u5927\u5c0f *\/\n  order: 1; \/* \u8c03\u6574\u987a\u5e8f *\/\n  align-self: center; \/* \u5355\u72ec\u5bf9\u9f50 *\/\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u9002\u7528\u573a\u666f<\/strong><\/h3>\n\n\n\n<p>\u2705&nbsp;<strong>\u6c34\u5e73\/\u5782\u76f4\u5c45\u4e2d\u5e03\u5c40<\/strong><br>\u2705&nbsp;<strong>\u7b49\u5bbd\/\u7b49\u9ad8\u6392\u5217<\/strong><br>\u2705&nbsp;<strong>\u54cd\u5e94\u5f0f\u5bfc\u822a\u680f<\/strong><br>\u2705&nbsp;<strong>\u5361\u7247\u5217\u8868\u81ea\u52a8\u6362\u884c<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2.&nbsp;<code>position: relative<\/code>\uff08\u76f8\u5bf9\u5b9a\u4f4d\uff09<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4f5c\u7528<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7528\u4e8e\u00a0<strong>\u5355\u4e2a\u5143\u7d20<\/strong>\uff0c\u4f7f\u5176\u00a0<strong>\u76f8\u5bf9\u4e8e\u81ea\u8eab\u539f\u672c\u7684\u4f4d\u7f6e<\/strong>\u00a0\u8fdb\u884c\u504f\u79fb\u3002<\/li>\n\n\n\n<li><strong>\u4e0d\u4f1a\u8131\u79bb\u6587\u6863\u6d41<\/strong>\uff0c\u5176\u4ed6\u5143\u7d20\u4ecd\u7136\u8ba4\u4e3a\u5b83\u5728\u539f\u6765\u7684\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e3b\u8981\u5c5e\u6027<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">.box {\n  position: relative; \/* \u76f8\u5bf9\u5b9a\u4f4d *\/\n  top: 10px; \/* \u5411\u4e0b\u504f\u79fb 10px *\/\n  left: 20px; \/* \u5411\u53f3\u504f\u79fb 20px *\/\n  z-index: 1; \/* \u63a7\u5236\u5c42\u7ea7 *\/\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u9002\u7528\u573a\u666f<\/strong><\/h3>\n\n\n\n<p>\u2705&nbsp;<strong>\u5fae\u8c03\u5143\u7d20\u4f4d\u7f6e\uff08\u4e0d\u5f71\u54cd\u5176\u4ed6\u5143\u7d20\uff09<\/strong><br>\u2705&nbsp;<strong>\u4f5c\u4e3a&nbsp;<code>absolute<\/code>&nbsp;\u5b9a\u4f4d\u7684\u53c2\u7167\u7236\u7ea7<\/strong>\uff08\u5b50\u5143\u7d20\u7528&nbsp;<code>position: absolute<\/code>&nbsp;\u65f6\uff0c\u4f1a\u76f8\u5bf9\u4e8e&nbsp;<code>relative<\/code>&nbsp;\u7236\u5143\u7d20\u5b9a\u4f4d\uff09<br>\u2705&nbsp;<strong>\u53e0\u52a0\u5143\u7d20\uff08\u5982\u6807\u7b7e\u3001\u5fbd\u7ae0\uff09<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3.&nbsp;<code>flex<\/code>&nbsp;\u548c&nbsp;<code>relative<\/code>&nbsp;\u7684\u533a\u522b<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7279\u6027<\/th><th><code>display: flex<\/code><\/th><th><code>position: relative<\/code><\/th><\/tr><\/thead><tbody><tr><td><strong>\u4f5c\u7528\u5bf9\u8c61<\/strong><\/td><td><strong>\u5bb9\u5668\uff08\u7236\u5143\u7d20\uff09<\/strong><\/td><td><strong>\u5355\u4e2a\u5143\u7d20<\/strong><\/td><\/tr><tr><td><strong>\u4e3b\u8981\u7528\u9014<\/strong><\/td><td><strong>\u63a7\u5236\u5b50\u5143\u7d20\u7684\u6392\u5217\u65b9\u5f0f<\/strong><\/td><td><strong>\u8c03\u6574\u81ea\u8eab\u4f4d\u7f6e<\/strong><\/td><\/tr><tr><td><strong>\u662f\u5426\u8131\u79bb\u6587\u6863\u6d41<\/strong><\/td><td>\u274c\uff08\u4ecd\u5728\u6587\u6863\u6d41\uff09<\/td><td>\u274c\uff08\u4ecd\u5728\u6587\u6863\u6d41\uff09<\/td><\/tr><tr><td><strong>\u662f\u5426\u5f71\u54cd\u5176\u4ed6\u5143\u7d20<\/strong><\/td><td>\u2705\uff08\u5b50\u5143\u7d20\u53d8\u4e3a Flex Item\uff09<\/td><td>\u274c\uff08\u4ec5\u81ea\u8eab\u504f\u79fb\uff09<\/td><\/tr><tr><td><strong>\u5e38\u89c1\u642d\u914d<\/strong><\/td><td><code>justify-content<\/code>,&nbsp;<code>align-items<\/code><\/td><td><code>top<\/code>,&nbsp;<code>left<\/code>,&nbsp;<code>z-index<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4. \u5b9e\u9645\u5e94\u7528\u793a\u4f8b<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u793a\u4f8b 1\uff1aFlexbox \u5b9e\u73b0\u6c34\u5e73\u5c45\u4e2d<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;div class=\"container\"&gt;\n  &lt;div class=\"item\"&gt;1&lt;\/div&gt;\n  &lt;div class=\"item\"&gt;2&lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n\n\n\n<p>\u8fd0\u884c HTML<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.container {\n  display: flex;\n  justify-content: center; \/* \u6c34\u5e73\u5c45\u4e2d *\/\n  gap: 10px;\n}\n.item {\n  background: lightblue;\n  padding: 10px;\n}<\/pre>\n\n\n\n<p><strong>\u6548\u679c<\/strong>\uff1a\u4e24\u4e2a&nbsp;<code>item<\/code>&nbsp;\u6c34\u5e73\u5c45\u4e2d\u6392\u5217\uff0c\u95f4\u8ddd&nbsp;<code>10px<\/code>\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u793a\u4f8b 2\uff1aRelative \u5fae\u8c03\u5143\u7d20\u4f4d\u7f6e<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;div class=\"box\"&gt;\u6b63\u5e38\u4f4d\u7f6e&lt;\/div&gt;\n&lt;div class=\"box relative-box\"&gt;\u76f8\u5bf9\u504f\u79fb&lt;\/div&gt;<\/pre>\n\n\n\n<p>\u8fd0\u884c HTML<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">.box {\n  background: lightcoral;\n  padding: 10px;\n}\n.relative-box {\n  position: relative;\n  top: 20px; \/* \u5411\u4e0b\u504f\u79fb 20px *\/\n  left: 30px; \/* \u5411\u53f3\u504f\u79fb 30px *\/\n}<\/pre>\n\n\n\n<p><strong>\u6548\u679c<\/strong>\uff1a\u7b2c\u4e8c\u4e2a&nbsp;<code>box<\/code>&nbsp;\u5411\u53f3\u4e0b\u65b9\u504f\u79fb\uff0c\u4f46\u5176\u4ed6\u5143\u7d20\u4e0d\u53d7\u5f71\u54cd\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5. \u603b\u7ed3<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u9009\u62e9\u65b9\u5f0f<\/th><th>\u9002\u7528\u573a\u666f<\/th><\/tr><\/thead><tbody><tr><td><strong><code>display: flex<\/code><\/strong><\/td><td>\u9700\u8981&nbsp;<strong>\u6574\u4f53\u5e03\u5c40\u63a7\u5236<\/strong>\uff08\u5982\u5bfc\u822a\u680f\u3001\u5361\u7247\u5217\u8868\u3001\u5c45\u4e2d\u6392\u5217\uff09<\/td><\/tr><tr><td><strong><code>position: relative<\/code><\/strong><\/td><td>\u9700\u8981&nbsp;<strong>\u5fae\u8c03\u5355\u4e2a\u5143\u7d20\u4f4d\u7f6e<\/strong>&nbsp;\u6216&nbsp;<strong>\u4f5c\u4e3a&nbsp;<code>absolute<\/code>&nbsp;\u7684\u53c2\u7167<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u8ba9&nbsp;<strong>\u591a\u4e2a\u5b50\u5143\u7d20\u81ea\u52a8\u6392\u5217<\/strong>\uff0c\u7528&nbsp;<strong><code>flex<\/code><\/strong>\uff1b<br>\u5982\u679c\u4f60\u60f3\u8ba9&nbsp;<strong>\u67d0\u4e2a\u5143\u7d20\u7a0d\u5fae\u504f\u79fb<\/strong>\uff0c\u7528&nbsp;<strong><code>relative<\/code><\/strong>\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6709\u5177\u4f53\u9700\u6c42\uff0c\u53ef\u4ee5\u544a\u8bc9\u6211\uff0c\u6211\u5e2e\u4f60\u5199\u4ee3\u7801\uff01 \ud83d\ude0a<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 CSS \u4e2d\uff0cflex&nbsp;\u548c&nbsp;relative&nbsp;\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u5e03\u5c40\u65b9\u5f0f\uff0c\u5206\u522b\u5c5e\u4e8e&nbsp;Flexbox\uff08\u5f39\u6027\u76d2\u5b50\uff09&nbsp;\u548c&nbsp;\u5b9a\u4f4d\uff08Positioning\uff09&nbsp;\u7cfb\u7edf\u3002\u5b83\u4eec\u7684\u4f5c\u7528\u548c\u7528\u6cd5\u5b8c\u5168\u4e0d\u540c\uff0c\u4e0b\u9762\u8be6\u7ec6\u89e3\u91ca\u5b83\u4eec\u7684&nbsp;\u4f7f\u7528\u65b9\u5f0f&nbsp;\u548c&nbsp;\u4e3b\u8981\u533a\u522b\u3002 1.&nbsp;display: flex\uff08\u5f39\u6027\u76d2\u5b50\u5e03\u5c40\uff09 \u4f5c\u7528 \u4e3b\u8981\u5c5e\u6027 \u5bb9&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-best-articles"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.3.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b - nimail blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.nimail.cn\/best-articles\/css-flex\u4e0erelative-\u7684\u4f7f\u7528\u548c\u533a\u522b\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b - nimail blog\" \/>\n<meta property=\"og:description\" content=\"\u5728 CSS \u4e2d\uff0cflex&nbsp;\u548c&nbsp;relative&nbsp;\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u5e03\u5c40\u65b9\u5f0f\uff0c\u5206\u522b\u5c5e\u4e8e&nbsp;Flexbox\uff08\u5f39\u6027\u76d2\u5b50\uff09&nbsp;\u548c&nbsp;\u5b9a\u4f4d\uff08Positioning\uff09&nbsp;\u7cfb\u7edf\u3002\u5b83\u4eec\u7684\u4f5c\u7528\u548c\u7528\u6cd5\u5b8c\u5168\u4e0d\u540c\uff0c\u4e0b\u9762\u8be6\u7ec6\u89e3\u91ca\u5b83\u4eec\u7684&nbsp;\u4f7f\u7528\u65b9\u5f0f&nbsp;\u548c&nbsp;\u4e3b\u8981\u533a\u522b\u3002 1.&nbsp;display: flex\uff08\u5f39\u6027\u76d2\u5b50\u5e03\u5c40\uff09 \u4f5c\u7528 \u4e3b\u8981\u5c5e\u6027 \u5bb9...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.nimail.cn\/best-articles\/css-flex\u4e0erelative-\u7684\u4f7f\u7528\u548c\u533a\u522b\/\" \/>\n<meta property=\"og:site_name\" content=\"nimail blog\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-25T01:31:26+00:00\" \/>\n<meta name=\"author\" content=\"\u4e00\u7ebf\u7801\u519c\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u4e00\u7ebf\u7801\u519c\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/\",\"url\":\"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/\",\"name\":\"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b - nimail blog\",\"isPartOf\":{\"@id\":\"https:\/\/blog.nimail.cn\/#website\"},\"datePublished\":\"2025-03-25T01:31:26+00:00\",\"author\":{\"@id\":\"https:\/\/blog.nimail.cn\/#\/schema\/person\/0b0e15eb489135cbe0643e4f5e8839af\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/blog.nimail.cn\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.nimail.cn\/#website\",\"url\":\"https:\/\/blog.nimail.cn\/\",\"name\":\"nimail blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.nimail.cn\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.nimail.cn\/#\/schema\/person\/0b0e15eb489135cbe0643e4f5e8839af\",\"name\":\"\u4e00\u7ebf\u7801\u519c\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/blog.nimail.cn\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cabb5645eed3060ef0005d4a179e6422ed56568f78c1b5d2326a4976200739c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cabb5645eed3060ef0005d4a179e6422ed56568f78c1b5d2326a4976200739c?s=96&d=mm&r=g\",\"caption\":\"\u4e00\u7ebf\u7801\u519c\"},\"sameAs\":[\"http:\/\/blog.nimail.cn\"],\"url\":\"https:\/\/blog.nimail.cn\/author\/longzg\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b - nimail blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.nimail.cn\/best-articles\/css-flex\u4e0erelative-\u7684\u4f7f\u7528\u548c\u533a\u522b\/","og_locale":"zh_CN","og_type":"article","og_title":"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b - nimail blog","og_description":"\u5728 CSS \u4e2d\uff0cflex&nbsp;\u548c&nbsp;relative&nbsp;\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u5e03\u5c40\u65b9\u5f0f\uff0c\u5206\u522b\u5c5e\u4e8e&nbsp;Flexbox\uff08\u5f39\u6027\u76d2\u5b50\uff09&nbsp;\u548c&nbsp;\u5b9a\u4f4d\uff08Positioning\uff09&nbsp;\u7cfb\u7edf\u3002\u5b83\u4eec\u7684\u4f5c\u7528\u548c\u7528\u6cd5\u5b8c\u5168\u4e0d\u540c\uff0c\u4e0b\u9762\u8be6\u7ec6\u89e3\u91ca\u5b83\u4eec\u7684&nbsp;\u4f7f\u7528\u65b9\u5f0f&nbsp;\u548c&nbsp;\u4e3b\u8981\u533a\u522b\u3002 1.&nbsp;display: flex\uff08\u5f39\u6027\u76d2\u5b50\u5e03\u5c40\uff09 \u4f5c\u7528 \u4e3b\u8981\u5c5e\u6027 \u5bb9...","og_url":"https:\/\/blog.nimail.cn\/best-articles\/css-flex\u4e0erelative-\u7684\u4f7f\u7528\u548c\u533a\u522b\/","og_site_name":"nimail blog","article_published_time":"2025-03-25T01:31:26+00:00","author":"\u4e00\u7ebf\u7801\u519c","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u4e00\u7ebf\u7801\u519c","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/","url":"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/","name":"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b - nimail blog","isPartOf":{"@id":"https:\/\/blog.nimail.cn\/#website"},"datePublished":"2025-03-25T01:31:26+00:00","author":{"@id":"https:\/\/blog.nimail.cn\/#\/schema\/person\/0b0e15eb489135cbe0643e4f5e8839af"},"breadcrumb":{"@id":"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.nimail.cn\/best-articles\/css-flex%e4%b8%8erelative-%e7%9a%84%e4%bd%bf%e7%94%a8%e5%92%8c%e5%8c%ba%e5%88%ab\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/blog.nimail.cn\/"},{"@type":"ListItem","position":2,"name":"CSS flex\u4e0erelative \u7684\u4f7f\u7528\u548c\u533a\u522b"}]},{"@type":"WebSite","@id":"https:\/\/blog.nimail.cn\/#website","url":"https:\/\/blog.nimail.cn\/","name":"nimail blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.nimail.cn\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/blog.nimail.cn\/#\/schema\/person\/0b0e15eb489135cbe0643e4f5e8839af","name":"\u4e00\u7ebf\u7801\u519c","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/blog.nimail.cn\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cabb5645eed3060ef0005d4a179e6422ed56568f78c1b5d2326a4976200739c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cabb5645eed3060ef0005d4a179e6422ed56568f78c1b5d2326a4976200739c?s=96&d=mm&r=g","caption":"\u4e00\u7ebf\u7801\u519c"},"sameAs":["http:\/\/blog.nimail.cn"],"url":"https:\/\/blog.nimail.cn\/author\/longzg\/"}]}},"_links":{"self":[{"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":1,"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/posts\/47\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nimail.cn\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}