Search code examples
htmltwitter-bootstrapgoogle-translatenavbar

Google Translate with fixed top navbar


I use Twitter Bootsrap's navbar to put a navigation bar on top of my website. (class="navbar navbar-fixed-top")
I also need to use Google Translate widget.
I use tools written here.

But when user selects a language to translate, Google puts a horizontal navbar on top of my page. That bar masks my own navbar. I need my navbar appear just below the Google's horizontal bar.

Should I use z-index ? But in that case one of them will mask other navbar? Is there a better solution? To show one of them below another? Thank you

edit: when I add following code to the top of my page, Google puts a navbar before my navbar, and everything seems well. But the bad thing is, Google's navbar is visible for every user. I need to show only to the users that doesn't speak my page's language.

<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'fr',
    layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL
  }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

edit: I suppose there is no option like "show google translate if language is different" and "show horizontal bar. If i load horizontal bar without considering the user's language everything is working fine. But the native speakers see the Google Translate bar. Which takes space from my page.


Solution

  • the easy option would be

    <div class="navbar-inner" style="padding-top:39px;">