• Resolved jaket89

    (@jaket89)


    Hi, Can anyone please help me fill in the CSS below to center the image:

    
    add_action('woocommerce_after_add_to_cart_button', 'add_content_on_add_to_cart_button');
    
    function add_content_on_add_to_cart_button() {
          echo "<img src='image.png' width="70%" />"; 
    }

    TIA

    • This topic was modified 3 years, 1 month ago by jaket89.
    • This topic was modified 3 years, 1 month ago by jaket89.
    • This topic was modified 3 years, 1 month ago by jaket89.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    Can you add a CSS class to the echo statement so you can style it in the customizer? Have you tried style=”margin: 0 auto;”?

    Is the image on a new line by itself?

    Thread Starter jaket89

    (@jaket89)

    Hi,
    The code is written exactly as you see it in the post above. This code is in the functions.php file.

    I tried adding your bit of code in-line, above and below but it didn’t work.

    Sorry but I’m a complete novice when it coems to this stuff.

    Thanks

    Mirko P.

    (@rainfallnixfig)

    Hi @jaket89!

    Can we take a look at the page where you have positioned the image that needs to be centered?

    Cheers.

    Thread Starter jaket89

    (@jaket89)

    Hi Mirko,

    I sorted it out. The answer was to edit the line as below:

    echo "<img src='https://simplysupersteals.com/wp-content/uploads/2021/10/GREY-PAYMENT_TRUST_BADGES.png' style='display:block;margin-left: 15%;width: 70%;'>" ;

    Thanks

    • This reply was modified 3 years, 1 month ago by jaket89.
    Mirko P.

    (@rainfallnixfig)

    Okay @jaket89! Thanks for letting us know.

    If you have any other questions please feel free to open a new thread.

    Cheers.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘CSS to Center Image’ is closed to new replies.