Detecting Google Chrome Translation

前端 未结 4 2185
难免孤独
难免孤独 2020-12-15 20:39

I\'ve added the Google Translation Bar to our website but due to how the layout works if the translation on the main navigation is longer than English is pushes some links d

4条回答
  •  無奈伤痛
    2020-12-15 21:10

    I know this is way late... and it's not a JS solution... but if you just need to be able to ensure you can style elements on your page when the Google Translate bar is being displayed, you can use CSS. The Translate code adds a class of "translated-ltr" (or "translated-rtl" if the language is right-to-left and not left-to-right like English) to the body tag.

    So you can use CSS classess like:

    .translated-ltr .nav, .translated-rtl .nav {}
    

    substituting the correct class/ID for your items as needed.

    Hope this helps!

提交回复
热议问题