Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Themes by

Please, see the following Screenshot. The search button should be in the right side of the search field (please see the arrow in the image), but it is shown at the bottom of the search field. How can I put it in the right place?

Q2A version: 1.7

1 Answer

+2 votes
selected by
Best answer

I faced this for the first time some months ago. The issue is extremely simple but took me a while to figure it out. If you see the code you'll see:

    <input type="text" name="q" value="" class="qa-search-field">
    <input type="submit" value="Search" class="qa-search-button">

The first input takes 100% of the width while the second one has a negative margin. The thing is that although the math looks good for both of them to be in the same line there is a not-so-visible thing between them. There is a blank character :)

As characters depend on the font size, blank characters from a font can be wider than blank characters from other fonts. The font used by default is called "Ubuntu" and it is downloaded from the Google Fonts service. Now, if you change the font to a wider one, for example "Helvetica" the magnifier button will collapse to the bottom. I see the "Welcome to Localhost..." is not using the Ubuntu font so it is highly likely this is the issue you're facing.

I can think of many alternatives to fix this. The simplest one would be to use the Ubuntu font, of course. If for some reason you don't have an internet connection available on your localhost, you could modify the CSS so that the first input's with, instead of being 100%, was slightly smaller. For example, for Helvetica, it breaks on 99.8% but works on 99.7%.

You can do this by modifying the percentage in this line: https://github.com/q2a/question2answer/blob/3ea14aef81c6c5a0fe192ae083fffd03daa254b8/qa-theme/SnowFlat/qa-styles.css#L199

Thanks a lot pupi1985! It works! :)