css 移动的上的媒体查询断点不工作

pieyvz9o  于 2022-12-24  发布在  其他
关注(0)|答案(2)|浏览(136)

我正在使用以下断点创建电子邮件,但在使用断点时遇到一些问题。
下面的断点在移动的上不起作用,实际上我在另一封电子邮件中使用了相同的断点,它工作得很完美。

<style style="" type="text/css">

body {
    -webkit-text-size-adjust: 100% !important;
    -ms-text-size-adjust: 100% !important;
    -webkit-font-smoothing: antialiased !important;
  }
  img {
    border: 0 !important;
    outline: 0 !important;
  }
  p {
    margin: 0 !important;
    padding: 0 !important;
  }
  table {
    border-collapse: collapse;
    mso-table-lspace: 0;
    mso-table-rspace: 0;
  }
  td {
    border-collapse: collapse;
    mso-line-height-rule: exactly;
  }
  a {
    border-collapse: collapse;
    mso-line-height-rule: exactly;
  }
  span {
    border-collapse: collapse;
    mso-line-height-rule: exactly;
  }
  .ExternalClass * {
    line-height: 100%;
  }
  span.MsoHyperlink {
    mso-style-priority: 99;
    color: inherit;
  }
  span.MsoHyperlinkFollowed {
    mso-style-priority: 99;
    color: inherit;
  }
  .em_defaultlink a {
    color: inherit !important;
    text-decoration: none !important;
  }
 

  @media only screen and (max-width: 4ii80px) {
    table[class="em_wrapper"] {
      width: 100% !important;
    }
  }
  @media only screen and (max-width: 480px) {
    table[class="em_main_table"] {
      width: 100% !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_aside"] {
      padding: 0 10px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    br[class="em_hide"],
    span[class="em_hide"],
    table[class="em_hide"],
    td[class="em_hide"] {
      display: none !important;
    }
  }
  @media only screen and (max-width: 480px) {
    img[class="em_full_img"] {
      width: 100% !important;
      height: auto !important;
    }
  }
  @media only screen and (max-width: 480px) {
    img[class="em_full_img1"] {
      width: 100% !important;
      height: auto !important;
      max-width: 100% !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_side"] {
      width: 10px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_spc_20"] {
      height: 20px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_gap_bottom"] {
      padding-bottom: 20px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_height_25"] {
      height: 25px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_f11"] {
      font-size: 11px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_height_35"] {
      height: 20px !important;
    }
  }
  @media only screen and (max-width: 480px) {
    td[class="em_text"] {
      font-size: 18px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    table[class="em_wrapper"] {
      width: 100% !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    table[class="em_main_table"] {
      width: 100% !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_aside"] {
      padding: 0 10px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    br[class="em_hide"],
    span[class="em_hide"],
    table[class="em_hide"],
    td[class="em_hide"] {
      display: none !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    img[class="em_full_img"] {
      width: 100% !important;
      height: auto !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    img[class="em_full_img1"] {
      width: 100% !important;
      height: auto !important;
      max-width: 100% !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_side"] {
      width: 10px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_spc_20"] {
      height: 20px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_gap_bottom"] {
      padding-bottom: 20px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_height_25"] {
      height: 25px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_f11"] {
      font-size: 11px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_height_35"] {
      height: 20px !important;
    }
  }
  @media only screen and (min-width: 481px) and (max-width: 599px) {
    td[class="em_text"] {
      font-size: 18px !important;
    }
  }

  @media only screen and (max-width: 600px) {
   .caption{
     font-size: 20px !important;
     color: red !important;
    
    }
}
  
    

 
</style>
5sxhfpxr

5sxhfpxr1#

如果你有(max-width: 4ii80px)这样的错误和某些构造,比如[class="em_hide"],一些邮件客户端--尤其是Gmail --会把你的整个<style>块都去掉。使用CSS和HTML验证器(网上有很多),但是忽略关于弃用代码的警告(HTML邮件使用了很多弃用代码就好了)。
使用https://www.caniemail.com/features/css-at-media/找出您应该期望的结果。
然后使用基本的CSS选择器,如.em_hide,而不是[class=“em_hide”]。
我也会将媒体查询打包在自己的<style>块中(是的,你可以有多个),因为其他一些东西只适用于某些电子邮件客户端,而Gmail不喜欢它们。(例如,Mso的东西只涉及Outlook桌面。

6ljaweal

6ljaweal2#

错误在于我键入的style标记,而不是〈style="”type=“text/css”〉

相关问题