Centering the Star Rating on Shopify (Legacy)

      Centering the Star Rating on Shopify (Legacy)


        Article Summary

        Products


        Reviews
        Supported plans

        Free, Starter, Pro, Premium, Enterprise

        eCommerce Platform

        Shopify, Shopify Plus

        In this article, you'll learn how to customize the Star Rating using external code.

        Available for:

        Merchants using the previous version of the Star Rating. If you’re using the new Star Rating, see this article

        Important to know

        • The code is generic and provided as is. Implementation or modification of this code is not supported by Yotpo
        • We recommend using the services of a developer for the purpose of integrating this customization into your website

        Aligning the star rating

        By default, the star rating is left-aligned. If you want to center-align the star rating, follow the instructions below according to the desired style.

        Please note:
        When the container <div> of the Star Rating is too small, Yotpo's text wraps and is left-aligned. The following fix will wrap the text correctly and center the elements.

        Setting it up

        Add the following CSS rule to the top of any parent template (ie. category.html / collection.liquid etc.). Avoid putting the code within the item template, as it will cause unnecessary repeats of the same CSS rule and may cause performance issues.

        <style>
        div.yotpo.bottomLine .pull-left {
        float: none;
        text-align: center;
        }
        
        .yotpo a.text-m {
        display: inline-block;
        }
        .yotpo .standalone-bottomline .star-clickable {
        display: inline-block;
        }
        </style>

        Troubleshooting

        Centering the Star Rating on Category pages may sometimes cause the Star Rating feature to be centered on the product pages as well.

        This happens if the code doesn't specify which of the Star Ratings should be centered, so it centers both.

        You can easily fix this issue by adding an ID to the code and the CSS rule. For example use this code on the Category Page:

        <div class="yotpo bottomLine" id= "category" style="display:inline-block"
                 data-product-id=" product.id ">
            </div>
              **      
          <style></style>

        A unique ID for the Category Page Star Rating insures that only this Star Rating will be centered, and all the other Star Ratings will remain left-aligned.


        Was this article helpful?