Gmail is ignoring “display:none”

后端 未结 12 2138
旧巷少年郎
旧巷少年郎 2020-12-08 02:14

I have a query that Gmail is ignoring display:none.

What to do? In email HTML for hiding a row or div.

12条回答
  •  我在风中等你
    2020-12-08 02:42

    For those reaching here with a similar problem relating to mobile/desktop email development in and Gmail - if you're using media queries and showing/hiding content, the embedded css will be unable to overwrite the inline !important declaration. Instead you can use overflow:hidden, like so :

    In your embedded media queries you will naturally undo these styles to reveal the div, and then hide the desktop version of the content.

    @media only screen and (max-width: 480px) {
     .mobile {
      display : block !important;
      width : auto !important;
      overflow : visible !important;
      float : none !important;
     }
     .desktop {
      display : none !important;
     }
    }
    

    Unfortunately the height property doesn't work in Gmail, otherwise it would be a better solution, given that this creates a section of whitespace below the visible content equal to the height of the div.

提交回复
热议问题