I am using google translator for my website. I want to hide the top bar of google translator let me know how i can hide that one?
Please check my site link here http://www.rewords.com and let me know i to hide that bar?
Thanks
I am using google translator for my website. I want to hide the top bar of google translator let me know how i can hide that one?
Please check my site link here http://www.rewords.com and let me know i to hide that bar?
Thanks
If anybody want javascript to do the job, add the snippet below in your document.ready
if(document.getElementsByClassName('goog-te-banner-frame skiptranslate')[0] !== undefined) {
document.getElementsByClassName('goog-te-banner-frame skiptranslate')[0].style.display = 'none';
document.body.style.top = '0px';
}
How it works: Google loads the toolbar to an iframe with class 'goog-te-banner-frame skiptranslate' and add 40px margin to top of html body. So we hide that frame and set body margin to '0px'.
Note: Refer to the attribution requirements by google https://cloud.google.com/translate/attribution
To this very time, solutions proposed here correctly hide the bar, yet the page remains shifted down 40px, hiding my footer and the bottom of my main frame.
After thinking about trapping body change event to look for the bar height and put it as a padding down my body, keeping the bar visible. Yet I found quite a light solution by adding a single line to google's required function itself, for it seems TranslateElement forces the body position to relative, making the CSS body{position useless to set.
HTML
<head>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage:'en'},'google_translate_element');
document.body.style.position="static"; /* << to counter overwriting by google func */
document.body.style.top="0px"; /* << force body pos here if not in CSS */
}
</script>
...
</head>
and just keep using the style changes some of you already proposed, thank you.
CSS
body > .skiptranslate { display: none; } /* << /!\ hides the bar */
I guess the next google move will be to also force body{top, so I prefer it in the JS call to their function.
Using some of the code from KDawg, adding margin-top and absolute positioning, I found this addition to the CSS to be the solution for positioning the hidden translation banner only, which doesn't appear until after a language is selected.
This solution does not affect positioning of translate button, or the language selector, which remains on the fixed header.
} iframe.goog-te-banner-frame {
position:absolute;
margin-top:30px;
We can achieve it using CSS, Just go and put below CSS code in style tag. That's it..!