Site logo

[Resolved] Search form slide down animation

Home Forums Support [Resolved] Search form slide down animation

Home Forums Support Search form slide down animation

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1525797
    George

    Is it possible to have the search form reveal like the example attached, or I am asking too much?

    #1525902
    Leo
    Staff
    Customer Support

    Hi George,

    I’d assume that the full animation would require some custom development – you can try to inspect their code and see how it was done.

    Something like this would create a simple version though:

    .navigation-search {
        top: 100%;
    }
    #1525910
    George

    Hi Leo, here is what I have so far, attached. I think I would need to change the search form markup to apply my changes, is there any way to do it in GP? Basically, I would need to add an icon and a search button.

    #1525950
    Elvin
    Staff
    Customer Support

    Hi,

    You can change the search form’s markup by using the generate_navigation_search_output filter.https://docs.generatepress.com/article/generate_navigation_search_output/

    As for the default CSS selectors for styling the search form:

    /* Height of the search textfield */
    .navigation-search input[type="search"] {
        height: 50px; 
    }
    /* padding and background for the search textfield's container */
    form.search-form.navigation-search.nav-search-active {
        padding: 50px;
        background: grey;
    }
    /* Setting the color of the icon */
    span.gp-icon.icon-search {
        background: [your icon bg color here];
        padding: 20px;
        border-radius: 50%;
        color: [your icon color here];
    }
    #1526029
    George

    Ok that was really helpful, Elvin. I made some progress but I would like some final help with the CSS.

    1. I need the grey background around the form to extend full-width, like the example.
    2. I need the magnifying glass inside the input field, like the example.
    3. I need the input field to extend and overlap the button so the button can sit on top of the search input field at the end, like the example.

    #1526058
    George

    Ok, I have fixed everything apart from the full-width functionality on desktop, any ideas?

    #1526065
    Elvin
    Staff
    Customer Support

    Hi,

    All seems in order now. Container looks full-width now on my end.

    Have you resolved this already?

    #1526085
    George

    I need to have the toggled search area with the grey background full-width like in the example I posted in my first post.

    #1526091
    Elvin
    Staff
    Customer Support

    Ah my bad.

    Add this CSS so the form goes full-width:

    form.search-form.navigation-search.nav-search-active {
        width: 100vw;
        margin-left: calc(-100vw / 2 + 100% / 2);
        margin-right: calc(-100vw / 2 + 100% / 2);
        max-width: 100vw;
    }

    After adding this, you’ll notice that your icon position will look weird.

    To address this, change your markup so the form contents are wrapped in a <div class="search-form-wrapper">.

    example:

    <form ...>
       <div class="earch-form-wrapper">
          <input ...>
          <input ...>
       </div>
    </form ...>

    and then style it w/ this.

    .search-form-wrapper {
        position: relative;
        width: 100%;
        display: flex;
        align-items: center;
    }
    .search-form span.gp-icon.icon-search {
        position: absolute;
        z-index: 99;
        color: #596678;
        left: 20px;
    }
    #1527384
    George

    Ok, got it, I managed to create what I wanted based on your suggestions. There seems to be a small issue, though. When searching for a term that cannot be found, the styling seems to have been carried over to the “Nothing Found” page and the search box is not as it should. Any ideas?

    #1527526
    Leo
    Staff
    Customer Support

    Can you link us to the page in question?

    Please be mindful that we have to careful with how much we help with a custom solution like this to be fair to everyone.

    #1527550
    George

    Yes, I am aware, actually, it’s all done now, it’s just the custom search styling affects the other form attached to the page when no results are found. Maybe there was a way to restyle the page search box?

    I have reattached site link.

    #1527612
    George

    Apologies, I sorted it out myself, just used a different class for the custom form markup.

    Thanks, Leo!

    #1527624
    Leo
    Staff
    Customer Support

    All Elvin on this one 🙂

    #1527629
    Elvin
    Staff
    Customer Support

    Apologies, I sorted it out myself, just used a different class for the custom form markup.

    Yeah we have to watch out for the class selectors that when we change the markup. 🙂

    Good catch! Glad you got it sorted. 🙂

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