AeroCore 主题专用图片居中 CSS,直接全选复制,粘贴到 AeroCore 设置 → 插入代码 → 自定义 CSS 样式 中即可:
/* =========================================
AeroCore 主题 - 文章图片强制居中
适用:经典编辑器 / 古腾堡 / 手动HTML
========================================= */
/* 1. WordPress 标准居中类 .aligncenter */
.single-article__content .aligncenter,
.single-article__content img.aligncenter {
display: block !important;
margin-left: auto !important;
margin-right: auto !important;
float: none !important;
}
/* 2. 针对 <p style="text-align:center"> 包裹的图片 */
.single-article__content p[style*="text-align: center"] img,
.single-article__content p[style*="text-align:center"] img {
display: inline-block;
margin: 0 auto;
vertical-align: middle;
}
/* 3. 古腾堡图片块 figure 居中 */
.single-article__content figure.aligncenter,
.single-article__content .wp-block-image.aligncenter {
display: block !important;
margin-left: auto !important;
margin-right: auto !important;
text-align: center !important;
}
/* 4. 图片响应式,防止超出容器 */
.single-article__content img {
max-width: 100%;
height: auto;
}
粘贴步骤
-
进入 WordPress 后台
-
点击左侧菜单 AeroCore 设置(或 主题设置)
-
找到 插入代码 → 自定义 CSS 样式
-
把上面代码完整粘贴进去
-
点击 保存
-
前台文章页按 Ctrl + F5 强制刷新
代码说明
注意:粘贴后如果仍不生效,请检查是否开启了缓存插件(如 WP Rocket),保存后记得清除缓存。