最佳答案
由于您无法将 css 添加到不存在的元素,因此您必须在单击翻译下拉 CTA 后添加它。这个 jquery 对我有用。
$('body').click('#google_translate_element', function () {
if (($goog = $('.goog-te-menu-frame').contents().find('body')).length) {
var stylesHtml = '<link rel="stylesheet" href="/css/google-translate.css">';
$goog.prepend(stylesHtml);
}
});
有了这个CSS。
.goog-te-menu2 {
width: 300px!important;
height: 300px!important;
overflow: auto!important;
}
.goog-te-menu2 table,
.goog-te-menu2 table tbody,
.goog-te-menu2 table tbody tr {
width: 100%!important;
height: 100%!important;
}
.goog-te-menu2 table tbody tr td {
width: 100%!important;
display: block!important;
}
.goog-te-menu2 table tbody tr td .goog-te-menu2-colpad {
visibility: none!important;
}
关于jquery - 谷歌翻译小部件移动溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38182485/