I want to position the search widget so it sits at the top right of the screen when displayed on desktop. It is left aligned but in the right place when viewed on mobile devices. However, it would look a little better if it was centered on mobile:
Just to make things clear: do you want to display the search in the top right corner (option 1) or align it to the right within the existing container (option 2)?
Hi Max, ideally I would like it to be position 1. I would move the navigation over to the left to allow the search on a desktop to sit to the right of the navigation.
We’ll be happy to customize the widget for you. However, could you first move the navigation so that there was enough space in the right corner for the search?
Hi Max, The latest CSS on the search widget worked great on desktop. However, it really messed up the menu on mobile view. I have gone back to the earlier CSS
Now the mobile view is good and some of the pages on desktop are good. However, the pages that drop down from the menu tab “Straight Tracks”. All the pages here are showing the search in the correct position but it is being squashed horizontally.
Sorry forgot to add if it’s some other code on my pages that can be amended to cure this problem. Then let me know.
To change the position of the search widget on desktop, you can use CSS to adjust its alignment. Try adding the following code to your stylesheet:
@media (min-width: 768px) {
.search-widget {
position: absolute; /* or fixed, depending on your layout /
top: 10px; / adjust as needed /
right: 10px; / adjust as needed */
}
}
@media (max-width: 767px) {
.search-widget {
text-align: center; /* to center on mobile */
}
}
This will position the search widget at the top right on desktop while allowing you to center it on mobile devices.
I have implemented similar changes in one of my projects website, where I also used specific CSS adjustments to enhance layout responsiveness.
Hopefully, this will help you out.