How to add a button to the header area?

When I use this code, it looks normal to the anonymous user. But it doesn’t look normal to the logged in user. The reason is the codes I used to center the search bar.