2014-09-19 51 views
0

我目前使用谷歌翻譯插上我的網站如何禁用谷歌翻譯插件並設置邊距:0px爲正文元素?

我alaready

.goog-te-banner-frame{ 
    visibility:hidden !important; 

CSS屬性禁用谷歌在上面翻譯吧。

但谷歌翻譯已成立的margin-top:40PX身體HTML塔格如下代碼

<body style="margin: 0px; padding: 0px; position: relative; min-height: 100%; top: 40px;"> 

所以,我的網站有上邊距,使我的網站錯了我的默認佈局的40像素。

請問我該如何設置CSS或Javascript來將我的上邊距修改爲0px;

請幫

回答

3

嘗試 body{top:0 !important;} 在你的CSS

+0

感謝有人做過,我可以使用圖標和其他自定義佈局 – hengsopheak 2014-09-19 08:44:43

0

如果有人想用JavaScript來做到這一點,這個片段添加到的document.ready

var toolBar = document.getElementsByClassName('goog-te-banner-frame skiptranslate')[0]; 
if(toolBar !== undefined) { 
    toolBar.style.display = 'none'; 
    document.body.style.top = '0px'; 
} 

它是如何工作: Google將工具欄加載到類名爲'goog-te-b'的iframe anner-frame skiptranslate'並在html正文的頂部添加40px頁邊距。所以我們隱藏這個框架並且設置body margin爲'0px'。

注意:由谷歌,請參閱歸屬需求現在https://cloud.google.com/translate/attribution