Google translator top bar hide

邮差的信 提交于 2019-11-30 09:47:57
Jacob Hodara

Done via CSS:

.goog-te-banner-frame.skiptranslate {display: none !important;} 
body { top: 0px !important; }

Some changes in Jacob's answer. Try writing,

<style type="text/css">iframe.goog-te-banner-frame{ display: none !important;}</style>
<style type="text/css">body {position: static !important; top:0px !important;}</style>

This will solve the issue.

hide by adding a javascript on your body onload event

document.getElementsByTagName("frameset")[0].rows="0,*;

The body element will fall into the flow - with static. Then you can properly use the display of none.

  body {top: 0px !important; position: static !important; }
    .goog-te-banner-frame {display:none !important}

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

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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!