简体   繁体   English

Gmail:大于内嵌CSS样式中定义的大小的元素

[英]Gmail: elements bigger than the size defined in inline css styles

So I'm coding html of an newsletter and i'm using the inline styles because of restrictions, so my "table layout" is broken because have elements with size bigger than the defined. 因此,我正在编写新闻简报的html,并且由于限制而使用了内联样式,因此我的“表布局”被破坏了,因为其元素的大小大于所定义的大小。 I realize that an element with 170px of height defined, and inside them have an tag with 170px of height defined, so why using inspect i can see that this have 172px, i think Gmail is ignoring something. 我意识到定义了高度为170px的元素,并且在其中定义了高度为170px的标签,因此为什么使用inspect我可以看到该元素的高度为172px,我认为Gmail会忽略某些内容。

I make a gif to show this in inspector: http://i.imgur.com/VqNsxrY.gif 我制作了一个gif以便在检查器中显示出来: http : //i.imgur.com/VqNsxrY.gif

My JSfiddle with my html: http://jsfiddle.net/wtkd/ygfn6qka/ (the boxes with images of mario shows where layout breaks) If you don't want to see in JSfiddle: 我的html带有我的JSfiddle: http : //jsfiddle.net/wtkd/ygfn6qka/ (带有mario图像的框显示了布局中断的地方)如果您不想在JSfiddle中看到:

  <table width="700" align="center" style="background-image: url('http://www.image.test.com/images/bg.jpg'); background-color: #ededed; background-position: center top; background-repeat: no-repeat; margin:0;padding:0;padding: 0; width: 700px; margin: 0 auto;">
<tr width="600" style="border-collapse:collapse;border-spacing:0;">
  <td style="border-collapse:collapse;border-spacing:0;">
    <table width="600" align="center" border="0" cellpadding="0" cellspacing="0" style=
    "border-collapse:collapse;border-spacing:0;">
      <thead width="600" style="border-collapse:collapse;border-spacing:0;">
        <tr width="600"height="150" style="border-collapse:collapse;border-spacing:0;">
          <th width="600" style="border-collapse:collapse;border-spacing:0;">
            <img src="http://www.image.test.com/images/header.png" width="600" height="151">
          </th>
        </tr>
        <tr height="104">
          <th style="height:104px; border-bottom: 5px #ededed solid;">
            <img src="http://www.image.test.com/images/update.png" width="600" height="104">
          </th>
        </tr>
      </thead>
      <tbody width="600">
        <tr height="170">
          <th height="170">
            <a style="height:170px;" href="http://www.test.com/motorola-droid-turbo/65466-moto-maxx-chega-oficialmente-brasil-preco-r-xxxx.htm" target="_blank"><img src="http://www.image.test.com/images/moto-maxx.png" width="600" height="170"></a>
          </th>
        </tr>
        <tr height="180">
          <th height="170">
            <a style="height:170px;" href="http://www.test.com/jogos/65442-explosivo-trailer-gameplay-gta-v-confirma-modo-primeira-pessoa.htm" target="_blank"><img src="http://www.image.test.com/images/gta-v.png" width="600" height="170"></a>
          </th>
        </tr>
        <tr>
          <table width="600" height="340" align="center" border="0" cellpadding="0" cellspacing="0" style=
            "border-collapse:collapse;border-spacing:0;">
            <tr>
              <th height="170" style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;">
                <a style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/moto-x/65400-analise-review-smartphone-motorola-novo-moto-x-2014.htm" target="_blank"><img src="http://www.image.test.com/images/moto-x.png" width="200" height="170"></a>
              </th>
              <th height="170" style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;">
                <a style="height: 170px; width: 200px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/iphone-6/64640-analise-apple-iphone-6-review.htm" target="_blank"><img src="http://www.image.test.com/images/iphone.png" width="200" height="170"></a>
              </th>
              <th rowspan="2" height="340" style="width: 200px; height: 340px;border-collapse:collapse;border-spacing:0;">
                <a style="width: 200px; height: 340px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/jogos/65339-personagens-super-mario-viram-brindes-mcdonalds-brasileiro.htm" target="_blank"><img src="http://img.elo7.com.br/product/original/62C89A/painel-mario-bros.jpg" width="200" height="340"></a>
              </th>
            </tr>
            <tr width="400" height="170">
              <th height="170" colspan="2" style="border-collapse:collapse;border-spacing:0;">
                <a style="width:400px;height:170px;border-collapse:collapse;border-spacing:0;" href="http://www.test.com/celular/65283-dinossauros-9-celulares-marcaram-epoca.htm" target="_blank"><img src="http://cdn.bgr.com/2013/11/super-mario-3d-world.jpg" width="400" height="170"></a>
              </td>
            </tr>
          </table>
        </tr>
        <tr>
          <table width="700" align="center" border="0" cellpadding="0" cellspacing="0" style=
              "border-collapse:collapse;border-spacing:0;background:#ededed;">
            <tr align="center" height="170" style="border-collapse:collapse;border-spacing:0;">
              <th height="170">
                <a href="http://www.test.com/cinema/65416-30-filmes-2015-voce-querer-ver-cinemas-estreias-lancamentos.htm" target="_blank"><img src="http://www.image.test.com/images/filmes.png" width="600" height="170"></a>
              </th>
            </tr>
            <tr height="180" align="center" style="border-collapse:collapse;border-spacing:0;">
              <td colspan="2" style="width:400px;height:170px;border-collapse:collapse;border-spacing:0;">
                <img src="http://www.image.test.com/images/grupo-nzn.jpg" width="600" height="180">
              </td>
            </tr>
          </table>
        </tr>
      </tbody>
    </table>
  </td>
</tr>

Someone can help about this? 有人可以帮忙吗?

You need to put display:block; 您需要输入display:block; inline on all your img tags. 内联在所有img标签上。

It's something related to the way <a> are displayed. 这与<a>的显示方式有关。 Changing their display property to block (individually, or globally with a style, and I'm curious to know why you are not allowed to use it) did the trick: running demo 改变他们的display属性以block (单独或全局地使用样式,我很好奇为什么不被允许使用它)达到了目的: 运行演示

<style>
    a {
        display : block;        
    }
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM