css - 为什么我的 margin css 在我的媒体查询中不起作用?

标签 css margin

我正在尝试创建一个电子邮件签名,当在移动设备上时,文本顶部与照片对齐。在桌面版上,我的上边距为 32px,媒体查询为 0px。知道为什么我的媒体查询不起作用吗?

@media only screen and (max-width: 500px) {
  .mobile {
    visibility: hidden;
    display: none;
  }

  .mtext {
    margin-top:0px; !important
    padding:0px; !important
  }
}
<table width="100%" border="0" style="font-family:Arial, Helvetica,sans-serif;font-size:12px; margin-left:10px; margin-right:10px;">
   <tr>
      <td width="100" valign="top" align="left">
         <img width="100px" src="https://www.pkallsc.org/wp-content/uploads/2018/04/Headshot-Jeffrey-Ashley-square-e1522622432938.jpg"  style="float:left;" alt="John Smith" />
      </td>
      <td width="1249" valign="top" style="text-align:left; margin-left:5px; font-family:Arial, Helvetica, sans-serif; font-size:16px;" align="left">
         <p class="mtext" style="margin-left:10px; margin-top:32px; font-family:Arial, Helvetica, sans-serif; font-size:14px; text-align:left;"> <strong>John&nbsp;Smith</strong>
            <br />Chief Executive Officer<br /> 123 Central Suite, Suite 510 |&nbsp;Alpharetta, Georgia 30022<br /> T 800.800.8808 | D 800.800.0236&nbsp;|&nbsp;F 800.800.2704
         </p>
      </td>
   </tr>
   <tr>
      <td colspan="3">
         <div class="mobile">
         <hr style="border: 1.5px solid #49DBC3; max-width: 550px; margin-left:0;" width="80%" align="left">
         <div>
   <tr> <td colspan="9" align="left"><div class="mobile"> 
   </div></td></tr><div> </div></div>
</table>

最佳答案

@media only screen and (max-width: 500px) {
  .mobile {
    visibility: hidden;
    display: none;
  }

  .mtext {
     margin-top:0px !important;
     padding:0px !important;
  }
}

如果你需要使用 !important 它应该在 ; 之前

关于css - 为什么我的 margin css 在我的媒体查询中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53765359/

相关文章:

css - 元素相互进入

html - 使用 ng-repeat 包装列

css - 为什么 p 背景没有正确定位?

html - 对齐按钮?

javascript - FA 图标没有出现在我的 html 元素的第二页中。怎么修?

html - 中心 DIV 内容流体垂直和水平

android - 向动态 Android TextView 添加边距

android - 如何在单选按钮和它的可绘制之间添加边距?

html - Flexbox 溢出滚动条显示在主体上而不是内部元素上

html - 如何删除正文周围的边距空间或清除默认的 css 样式