Archived topic
Styling the search bar to drop down
13 replies · Started by Margot on November 16, 2017
Hi!
I'm having trouble with my search box which is displaying to the right of my navigation bar. I want it to drop down like the rest of my subnavigation drop downs. Any adice on how to style this would be wonderful. Thank you!
First you'll want to remove this CSS:
input {
position: absolute;
opacity: 0;
z-index: -1;
}
Then you could do something like this:
form.search-form.navigation-search {
max-width: 200px;
top: 45px;
z-index: 10;
border: 1px solid #DDD;
border-top: 0;
}
That's exactly what I was looking to do. One quick question, when the bar navigation bar becomes sticky, the search box shifts to the right, any way to change this?
Thank you for all of your help!
Any chance you can remove and add my CSS recommendations above? I'm not seeing them added yet.
Yes! Sorry, I was working locally but I updated it on the server. I also noticed that I set my mobile breakpoint to 1000px wide via the code you suggested on Github but the transition is strange with the hamburger icon going left first before it snaps right. Should I start a new topic about that?
Just to double check, this is the code you've used to change the breakpoint?
https://gist.github.com/generatepress/282078076cd8631c17717d5b8640c043
You know what... it appears I had an outdated one. That one fixed the hamburger icon, but I'm still running into issues with the sticky instance of the search box. My apologies for not seeing that updated code. That was my oversight.
Can you edit Tom's code to this:
@media (min-width:769px) {
form.search-form.navigation-search {
max-width: 200px;
top: 45px;
z-index: 10;
border: 1px solid #DDD;
border-top: 0;
}
}
Hi Leo, it's been updated but there's still that shift happening. Not sure if that was supposed to fix it?
You have padding applied to the outer navigation element when not stuck, and then to the inner navigation element when stuck. If you choose one or the other (inner is better), the shift should disappear.
Hi Tom, I'm having trouble locating the selector for the outer/inner navigation element you mentioned. If you could just let me know the names of those selectors, I can make the edits. Thank so much for your help and patience!
It should be this: nav#sticky-navigation .inside-navigation
The other one with padding is: nav#site-navigation
Perfect! Thank you again!!
You're welcome :)