- This topic has 16 replies, 3 voices, and was last updated 4 years, 10 months ago by
Elvin.
-
AuthorPosts
-
November 10, 2020 at 10:58 am #1525797
George
Is it possible to have the search form reveal like the example attached, or I am asking too much?
November 10, 2020 at 1:24 pm #1525902Leo
StaffCustomer SupportHi 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%; }
November 10, 2020 at 1:40 pm #1525910George
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.
November 10, 2020 at 2:20 pm #1525950Elvin
StaffCustomer SupportHi,
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]; }
November 10, 2020 at 3:39 pm #1526029George
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.November 10, 2020 at 5:03 pm #1526058George
Ok, I have fixed everything apart from the full-width functionality on desktop, any ideas?
November 10, 2020 at 5:15 pm #1526065Elvin
StaffCustomer SupportHi,
All seems in order now. Container looks full-width now on my end.
Have you resolved this already?
November 10, 2020 at 5:54 pm #1526085George
I need to have the toggled search area with the grey background full-width like in the example I posted in my first post.
November 10, 2020 at 6:12 pm #1526091Elvin
StaffCustomer SupportAh 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; }
November 11, 2020 at 12:50 pm #1527384George
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?
November 11, 2020 at 3:07 pm #1527526Leo
StaffCustomer SupportCan 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.
November 11, 2020 at 3:44 pm #1527550George
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.
November 11, 2020 at 5:52 pm #1527612George
Apologies, I sorted it out myself, just used a different class for the custom form markup.
Thanks, Leo!
November 11, 2020 at 6:31 pm #1527624Leo
StaffCustomer SupportAll Elvin on this one 🙂
November 11, 2020 at 6:46 pm #1527629Elvin
StaffCustomer SupportApologies, 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. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.