AeroCore Free 主题文章默认图片居中

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;
}

粘贴步骤

  1. 进入 WordPress 后台
  2. 点击左侧菜单 AeroCore 设置(或 主题设置
  3. 找到 插入代码自定义 CSS 样式
  4. 把上面代码完整粘贴进去
  5. 点击 保存
  6. 前台文章页按 Ctrl + F5 强制刷新

代码说明

注意:粘贴后如果仍不生效,请检查是否开启了缓存插件(如 WP Rocket),保存后记得清除缓存
上一篇 WordPress重复标题与内容检测器 —— 让重复内容无处遁形,精准守护站点原创性