阻止 Google Translator 将 html 高度更改为 100%
我向网站添加了 Google 翻译小部件(使用此处提供的代码:http://translate.google.com/translate_tools )并有以下问题:
它自动向 html 标记添加一个 style 属性,其值包括:
height: 100%
这是“破坏”页面布局。例如,原来定位在“底部”的 CSS 背景图像现在(错误地)定位在视口的底部。
有什么办法可以预防或解决这个问题吗?
I added a Google Translator widget to a site (using the code provided here: http://translate.google.com/translate_tools) and have the following issue:
It automatically adds a style attribute to the html tag whose value includes:
height: 100%
This is "breaking" the page layout. For example, CSS backround images that were positioned to "bottom" are now (incorrectly) positioned at the bottom of the view port.
Is there any way to prevent or fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
这解决了这个问题:
This resolves the issue:
我可以通过将 css 中的 body min-height 属性设置为 !important 以防止覆盖来解决此问题。
更新 - 不幸的是,这不再有效。 Google 翻译脚本将删除您为对抗其 min-height 风格所做的任何尝试。我的样式表中有上述 CSS,body 标签上有内联样式。
谷歌翻译脚本非常激进,我没有看到任何方法来禁用它。
I was able to solve this by setting the body min-height attribute in css as !important to prevent override.
UPDATE - Unfortunately, this no longer works. The Google Translation script will strip out any attempts you make to counter it's min-height style. I have both the above CSS in my stylesheet AND an inline style on the body tag.
The Google Translation script is pretty aggressive and I'm not seeing any way to disable this.
这应该有效:
This should work:
也许就像
body{ height: auto !important; }
maybe it's like
body{ height: auto !important; }
不要在head部分写css,写在css文件中。这将阻止谷歌自动翻译。
do not write css in head part, write in a css file. this will preventing automatic translation by google.
我尝试使用其他答案提供的解决方案,但它们对我不起作用。如果其他人也遇到此问题,我确实通过此解决方案取得了成功。
I tried using the solutions provided by the other answers, but they didn't work for me. If anyone else is having this issue, I did have success with this solution.
我找到了解决这个问题的方法,我想它不是防弹的,但现在可以使用:
插件: http://darcyclarke.me/dev/watch/
使用此代码:)
I found a way to solve this issue, it's not bulletproof I guess but works for now:
Plugin: http://darcyclarke.me/dev/watch/
with this code :)
我认为解决这个问题的唯一方法是在代码上设置 500 毫秒的超时来重置 body min-height 属性。如果您不介意页面在加载时跳跃半秒,那么它就可以了。使用 jquery,它看起来像这样:
将 myMinHeight 的值设置为您希望的值。
The only way I can see to combat this is to put a timeout of 500ms on code to reset the body min-height property. If you're not to bothered about your page jumping around a little for half a second on load, it works. Using jquery, it would look something like this:
Set the value of myMinHeight to whatever you wish it to be.