[Support request] Center a shortcode in a GeneratePress Element

Home Forums Support [Support request] Center a shortcode in a GeneratePress Element

Home Forums Support Center a shortcode in a GeneratePress Element

  • This topic has 3 replies, 2 voices, and was last updated 4 years ago by Leo.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #903161
    Henry

    Here’s my shortcode (which I have placed in the functions.php and works great).

    This function simply shows the generic WordPress Search Form:

    function shapeSpace_display_search_form() {
    	return get_search_form(false);
    }
    add_shortcode('display_search_form', 'shapeSpace_display_search_form');

    In a Hook Element, I’d like to center the search form – that’s it.

    I thought something simple like this would work:

    <div class="center">
    [display_search_form]
    </div>

    However, it just aligns to the left.

    Any ideas?

    Thanks

    #903166
    Leo
    Staff
    Customer Support

    Hi there,

    A class doesn’t actually mean anything without CSS targetting it.

    You can either use HTML inline style:
    https://www.w3schools.com/html/html_styles.asp
    https://www.w3schools.com/cssref/pr_text_text-align.asp

    Or target the class with CSS:

    .center {
        text-align: center;
    }

    This site is excellent for learning basic HTML and CSS if you are interested:
    https://www.codecademy.com/

    #903190
    Henry

    Thansk Leo -yes, I knew that – I just thought that GP has that .center class baked in.

    Thanks again!!

    #903195
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.