Theme Overrides Image Centering Class

Created on 7 July 2025, 6 days ago

I'm trying to center an image and text in a view that's displayed in a block. The view preview looks fine with the image (field 1) centered in the block, and the text (field 2) centered below it. When the block is displayed in the content region, the image is left-aligned, but the text remains centered. Is there something in the theme settings that would override the class setting for the image?

I'm adjusting the style settings for both fields in the view, with "Customize field HTML" and "Add HTML class" checked, the "p" element selected, and the ".text-align-center" class specified. My browser debugger confirms that the HTML element and class are present.

πŸ’¬ Support request
Status

Active

Version

1.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States sah62 US

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sah62
  • πŸ‡ΊπŸ‡ΈUnited States sah62 US

    Sorry, I should note that I use the Claro Admin theme. The image is properly centered when the view preview is shown using this theme.

  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    Hello,

    Thank you for bringing this to my attention.

    I have updated the theme so that img, video, object, and embed elements now correctly inherit alignment from their wrapper, ensuring they center as expected when using .text-align-center.

    Solution:
    You can download the latest dev version, which includes this fix.
    If you prefer to patch it manually, add the following CSS under Theme Settings > Global Site > CSS Injector:

    #page-wrapper .text-align-center img,
    #page-wrapper .text-align-center video,
    #page-wrapper .text-align-center object,
    #page-wrapper .text-align-center embed {
      margin-left: auto;
      margin-right: auto;
    }

    Best wishes,
    Alaa

  • πŸ‡ΊπŸ‡ΈUnited States sah62 US

    Thanks! As a test, I added the CSS Injector settings as you suggested. The image is still left-justified. If it helps, you can see my site here:

    https://www.musclecarresearch.com/

    The "Featured Product" views block is at the top of the content region. The off-center image can't be missed.

  • πŸ‡ΊπŸ‡ΈUnited States sah62 US

    I figured out a way to center the image, but it's a hack. I added the following CSS to Theme Settings > Global Site > CSS Dynamic:

    a.img--is-clickable > img.solo-image, a.img--is-clickable > picture > img.solo-image {
        width: 100%;
        float: none !important;
    }

    float: none !important; is what did the trick.

  • πŸ‡ΊπŸ‡ΈUnited States flashwebcenter Austin TX

    Hello,

    Yes, it is correct. The image is nested inside a clickable anchor that was previously using float: left. Disabling the float will fix it.

    #page-wrapper .text-align-center img,
    #page-wrapper .text-align-center video,
    #page-wrapper .text-align-center object,
    #page-wrapper .text-align-center embed {
      margin-left: auto;
      margin-right: auto;
      float: none;
    }

    Best wishes,
    Alaa

  • πŸ‡ΊπŸ‡ΈUnited States sah62 US

    Confirmed. Adding float: none; to the CSS you provided works.

Production build 0.71.5 2024