The discussion revolves around centering the header search bar on a Discourse forum, with user ogulcan1787 seeking help as the search bar’s position shifts depending on user login status and language (Turkish). The issue stems from differing widths of header elements—such as login buttons and the search bar—causing misalignment. Lilly and awesomerobot explain that the header’s center shifts based on content width, making consistent centering difficult. awesomerobot clarifies that the problem is due to asymmetrical content width and suggests using CSS to adjust margins. ogulcan1787 shares a workaround using margin-left and margin-right adjustments to center the search bar, acknowledging the complexity and ongoing challenges with CSS alignment.
I wrote these codes, when I add them to the css field, it looks the way I want, but it doesn’t look like that in others.
Can you help me pls ? https://pvpfarm.com
Hi helpful friends.
How can I center this?
It looks different when logged in. It looks different after logging in.
I want it to always stay right in the middle and in the same position.
why are you showing the search bar for anon users? nevermind. I’m there now. I thought clicking the search bar would bring up the login modal but it does let me search… having a quick look.
I’m finding it all very buggy in Chrome on my Macbook. Header buttons are opening the wrong menus and trying to close the chat drawer opens the hamburger menu etc.
I don’t have an answer as to why - my guess is that there are some conflicting SCSS. You and your forum are coming along though - don’t get discouraged; compared to when you first started here, your site looks a lot better. CSS is tricky if you have no experience and a lot can get messy in a hurry if you are not careful. Just take your time and read some of the Documentation knowledge-base topics here. I think if you simplify and streamline some of your CSS, you’ll figure out the issues.
I’m very surprised right now , I don’t have such a problem either. Maybe this problem is occurring because you translated the language of the site? The main language of the site is Turkish.
I will check this on my macbook soon
I would really like to minimize the codes but it was very complicated.
I can give you admin authority. You can witness how complicated.
The header content and page content are centered independently from each other, so if for example, the header has more content on the left or right the header’s center will be different.
Here are some illustrations of this, here the header’s “center” changes based on the amount of content on the right:
There’s not a simple way to ensure the center of both the header and the page content are always the same, especially considering the width of header content may change (due to translations, number of buttons, etc).
This works because the content on the left (logo) is now the same width as the content on the right (button container). You’ll need a separate bit of CSS to target .anon (logged out) because different buttons are shown on the right. Translations as you noticed, will also make buttons a different size, so that will impact alignment.