{"id":2862,"date":"2020-04-18T20:55:11","date_gmt":"2020-04-18T12:55:11","guid":{"rendered":"http:\/\/www.yuguoxy.com\/geekhome\/?p=2862"},"modified":"2026-08-18T12:35:29","modified_gmt":"2026-08-18T04:35:29","slug":"css%e5%b8%83%e5%b1%80%e7%b3%bb%e5%88%97-%e5%b1%85%e4%b8%ad%e7%9b%b8%e5%85%b3%e7%9a%84%e5%b8%83%e5%b1%80","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=2862","title":{"rendered":"css\u5e03\u5c40\u7cfb\u5217-\u5c45\u4e2d\u76f8\u5173\u7684\u5e03\u5c40"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\u5c45\u4e2d\u662f CSS \u5e03\u5c40\u91cc\u6700\u5e38\u88ab\u95ee\u5230\u7684\u4e00\u5757\uff1a\u6c34\u5e73\u3001\u5782\u76f4\u3001\u6c34\u5e73\u5782\u76f4\u4e09\u5957\uff0c\u65b9\u6848\u4ece <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">text-align<\/code>\u3001<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">margin: 0 auto<\/code> \u5230\u5b9a\u4f4d <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">transform<\/code> \u518d\u5230 <strong style=\"color: #4870ac;\">Flex<\/strong>\u3002\u4e0b\u9762\u6309\u6548\u679c\u628a\u80fd\u7528\u7684\u5199\u6cd5\u6536\u9f50\uff0c\u5e76\u6807\u51fa\u7ee7\u627f\u6027\u548c\u8131\u79bb\u6587\u6863\u6d41\u65f6\u7684\u5751\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u9009\u65b9\u6848\u65f6\u5148\u95ee\u4e09\u4ef6\u4e8b\uff1a\u5b50\u5143\u7d20\u662f\u5426\u5757\u7ea7\u3001\u662f\u5426\u5df2\u8131\u79bb\u6587\u6863\u6d41\u3001\u8981\u4e0d\u8981\u517c\u5bb9\u8001\u6d4f\u89c8\u5668\u3002\u80fd\u7528 Flex \u5c31\u6700\u7701\u4e8b\uff1b\u5fc5\u987b\u517c\u5bb9\u65f6\u518d\u9000\u56de\u5b9a\u4f4d\u6216 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">table-cell<\/code>\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u76ee\u6807<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u5e38\u7528\u65b9\u6848<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u6ce8\u610f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6c34\u5e73\u5c45\u4e2d<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">inline-block + text-align\uff1b\u5b9a\u4f4d + transform\uff1bblock + margin: 0 auto\uff1bflex<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">text-align \u4f1a\u7ee7\u627f\uff1b\u8131\u79bb\u6587\u6863\u6d41\u65f6 margin auto \u5931\u6548<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5782\u76f4\u5c45\u4e2d<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5b9a\u4f4d + transform\uff1btable-cell + vertical-align\uff1bflex\uff1b\u884c\u9ad8\u7b49\u4e8e\u9ad8<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">vertical-align \u4f1a\u7ee7\u627f\uff1btransform \u6709\u517c\u5bb9\u95ee\u9898<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6c34\u5e73\u5782\u76f4<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u5b9a\u4f4d + translate(-50%,-50%)\uff1btable-cell + margin auto\uff1bflex \u53cc center<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Flex \u6700\u7701\uff0c\u4f46\u8981\u8003\u8651\u517c\u5bb9<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u6c34\u5e73\u5c45\u4e2d<\/h2>\n<p style=\"margin: 1em 0px;\">\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/middle1.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2863\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/middle1.png\" alt=\"middle1\" width=\"728\" height=\"106\" \/><\/a><\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e00. inline-block + text-align<\/h3>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">display: inline-block<\/code> \u7684\u5143\u7d20\u5e26\u6709\u6587\u672c\u6027\u8d28\uff0c\u7236\u5143\u7d20\u53ef\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">text-align: center<\/code> \u505a\u884c\u5185\u6c34\u5e73\u5bf9\u9f50\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">text-align<\/code> \u4f1a\u7ee7\u627f\uff0c\u5185\u90e8\u6587\u5b57\u4e5f\u4f1a\u5c45\u4e2d\uff0c\u9700\u8981\u81ea\u8eab\u518d\u8bbe\u4e00\u6b21\u8986\u76d6\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        width: 100%;\n        height: 200px;\n        background-color: aqua;\n        text-align: center;\n    }\n    .content {\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n        display: inline-block;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e8c. \u5b9a\u4f4d + transform<\/h3>\n<p style=\"margin: 1em 0px;\">\u7236\u7ea7\u5f00\u5b9a\u4f4d\uff08relative \/ absolute \/ fixed \u5747\u53ef\uff09\uff0c\u5b50\u7ea7 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">absolute<\/code> \u540e <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">left: 50%<\/code>\uff0c\u518d\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">transform: translateX(-50%)<\/code> \u56de\u9000\u81ea\u8eab\u5bbd\u5ea6\u7684 50%\u3002\u7236\u7ea7\u662f\u5426\u8131\u79bb\u6587\u6863\u6d41\u4e0d\u5f71\u54cd\u6c34\u5e73\u5c45\u4e2d\uff1b<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">transform<\/code> \u662f CSS3\uff0c\u6709\u517c\u5bb9\u95ee\u9898\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        position: relative;\n        width: 100%;\n        height: 200px;\n        background-color: aqua;\n    }\n    .content {\n        position: absolute;\n        left: 50%;\n        transform: translateX(-50%);\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e09. display: block + margin: 0 auto<\/h3>\n<p style=\"margin: 1em 0px;\">\u53ea\u6539\u5b50\u5143\u7d20\u5373\u53ef\u3002margin \u4e3a auto \u65f6\u6d4f\u89c8\u5668\u5de6\u53f3\u5747\u5206\u3002\u5b50\u5143\u7d20 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">display<\/code> \u8bbe\u4e3a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">block<\/code> \u6216 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">table<\/code> \u90fd\u884c\uff1b\u4e00\u65e6\u6d6e\u52a8\u6216\u5b9a\u4f4d\u8131\u79bb\u6587\u6863\u6d41\uff0cmargin \u503c\u4f1a\u5931\u6548\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        width: 100%;\n        height: 200px;\n        background-color: aqua;\n    }\n    .content {\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n        display: table;\n        margin: 0 auto;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u56db. Flex<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n\/* flex *\/\n.wrap{\n    display: flex;\n    justify-content: center;\n}\n&lt;\/style&gt;\n&lt;body&gt;\n   &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001\u5782\u76f4\u5c45\u4e2d<\/h2>\n<p style=\"margin: 1em 0px;\">\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/vertifimiddle.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2864\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/vertifimiddle.png\" alt=\"vertifimiddle\" width=\"177\" height=\"529\" \/><\/a><\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e00. \u5b9a\u4f4d + transform<\/h3>\n<p style=\"margin: 1em 0px;\">\u548c\u6c34\u5e73\u65b9\u6848\u4e8c\u540c\u4e00\u601d\u8def\uff0c\u628a left \/ translateX \u6362\u6210 top \/ translateY\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        position: relative;\n        width: 200px;\n        height: 600px;\n        background-color: aqua;\n    }\n    .content {\n        position: absolute;\n        top: 50%;\n        transform: translateY(-50%);\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e8c. display: table-cell + vertical-align<\/h3>\n<p style=\"margin: 1em 0px;\"><code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">display: table-cell<\/code> \u884c\u4e3a\u7c7b\u4f3c td\uff0c\u5b50\u5143\u7d20\u5e03\u5c40\u50cf\u6587\u672c\uff0c\u7236\u7ea7 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">vertical-align: middle<\/code> \u5373\u53ef\u5782\u76f4\u5c45\u4e2d\u3002\u8be5\u5c5e\u6027\u4f1a\u7ee7\u627f\uff0c\u7236\u7ea7\u5185\u6587\u672c\u4e5f\u4f1a\u5782\u76f4\u5c45\u4e2d\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        display: table-cell;\n        vertical-align: middle;\n        width: 200px;\n        height: 600px;\n        background-color: aqua;\n    }\n    .content {\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e09. Flex<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n\/* flex *\/\n.wrap{\n    display: flex;\n    \/* flex-direction: column;\n    justify-content: center; *\/\n    align-items: center;\n}\n&lt;\/style&gt;\n&lt;body&gt;\n     &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u56db. \u56fa\u5b9a\u9ad8\u5ea6\u7b49\u4e8e\u884c\u9ad8<\/h3>\n<p style=\"margin: 1em 0px;\">content \u53ef\u4ee5\u662f\u884c\u5185\u6216\u5757\u7ea7\u5143\u7d20\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n\/* content \u53ef\u4ee5\u662f\u884c\u6216\u5757\u5143\u7d20 *\/\n.wrap{\n    height:300px;\n    line-height: 300px;\n}\n&lt;\/style&gt;\n&lt;body&gt;\n     &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001\u6c34\u5e73\u5782\u76f4\u5c45\u4e2d<\/h2>\n<p style=\"margin: 1em 0px;\">\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/middle2.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2865\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/middle2.png\" alt=\"middle2\" width=\"566\" height=\"368\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/middle2.png 566w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/middle2-90x60.png 90w\" sizes=\"(max-width: 566px) 100vw, 566px\" \/><\/a><\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e00. \u5b9a\u4f4d + transform<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        position: relative;\n        width: 1200px;\n        height: 800px;\n        background-color: aqua;\n    }\n    .content {\n        position: absolute;\n        left: 50%;\n        top: 50%;\n        transform: translate(-50%, -50%);\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u65b9\u6848\u4e8c. \u6c34\u5e73\u65b9\u6848\u4e09 + \u5782\u76f4\u65b9\u6848\u4e8c<\/h3>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">&lt;style&gt;\n    .wrap {\n        display: table-cell;\n        vertical-align: middle;\n        width: 1200px;\n        height: 800px;\n        background-color: aqua;\n    }\n    .content {\n        margin: 0 auto;\n        width: 200px;\n        height: 200px;\n        background-color: blueviolet;\n    }\n&lt;\/style&gt;\n&lt;body&gt;\n    &lt;div class=\"wrap\"&gt;\n        &lt;div class=\"content\"&gt;&lt;\/div&gt;\n    &lt;\/div&gt;\n&lt;\/body&gt;<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u56db\u3001\u7528 Flex \u4e00\u6b21\u505a\u5b8c<\/h2>\n<p style=\"margin: 1em 0px;\">\u9ed8\u8ba4\u4ea4\u53c9\u8f74 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">align-items: center<\/code> \u5782\u76f4\u5c45\u4e2d\uff0c\u4e3b\u8f74 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">justify-content: center<\/code> \u6c34\u5e73\u5c45\u4e2d\u3002\u4ecd\u8981\u8003\u8651\u6d4f\u89c8\u5668\u517c\u5bb9\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\"> &lt;style&gt;\n     .wrap {\n         display: flex;\n         align-items: center;\n         justify-content: center;\n         width: 1200px;\n         height: 800px;\n         background-color: aqua;\n     }\n     .content {\n         width: 200px;\n         height: 200px;\n         background-color: blueviolet;\n     }\n &lt;\/style&gt;\n &lt;body&gt;\n     &lt;div class=\"wrap\"&gt;\n         &lt;div class=\"content\"&gt;&lt;\/div&gt;\n     &lt;\/div&gt;\n &lt;\/body&gt;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u539f\u6587: https:\/\/juejin.im\/post\/5e91a8a56fb9a03c9037928f#heading-12<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u6c34\u5e73\u3001\u5782\u76f4\u3001\u6c34\u5e73\u5782\u76f4\u90fd\u53ef\u4ee5\u7528\u5b9a\u4f4d\u52a0 transform \u6216 Flex \u89e3\u51b3\uff1bmargin auto \u548c table-cell \u662f\u517c\u5bb9\u5907\u9009\uff0c\u8bb0\u4f4f\u7ee7\u627f\u548c\u8131\u79bb\u6587\u6863\u6d41\u4f1a\u8ba9\u90e8\u5206\u65b9\u6848\u5931\u6548\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5c45\u4e2d\u662f CSS \u5e03\u5c40\u91cc\u6700\u5e38\u88ab\u95ee\u5230\u7684\u4e00\u5757\uff1a\u6c34\u5e73\u3001\u5782\u76f4\u3001\u6c34\u5e73\u5782\u76f4\u4e09\u5957\uff0c\u65b9\u6848\u4ece text-align\u3001margin: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[109,105],"tags":[134,150],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2862"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2862"}],"version-history":[{"count":2,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2862\/revisions"}],"predecessor-version":[{"id":2867,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/2862\/revisions\/2867"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}