Why does the first image in this table only link part of the image to its hyperlink, but the second one works fine?

huangapple go评论56阅读模式
英文:

Why does the first image in this table only link part of the image to its hyperlink, but the second one works fine?

问题

I'm unsure why the link for the first image in the table is messed up since it has the same structure as the second image which does work fine, it's just in a different location. I've copied the relevant sections of html below as block code.

我不确定为什么表格中第一张图片的链接出了问题,因为它的结构与第二张图片相同,而第二张图片却正常工作,只是位置不同。我已将相关的HTML部分复制如下,作为代码块:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

#webpage {

width: 1000px ;

margin-left: auto ;

margin-right: auto ;

}

/* Pennant pos */

.pennant {

padding: 0px 0px;

position: absolute;

}

/* Logo pos */

.logo {

padding: 300px 0px;

position: absolute;

}

<!-- language: lang-html -->

<body style="color:white">
  <div id="webpage">
    <hr id="home">
    <br>
    <table width="100%" border="0">
      <tbody>
        <tr>
          <td valign="Top" align="Left">
            <div class="pennant">
              <a href="https://link1.com/">
                <img src="pennant.png" width="350" height="226">
              </a>
            </div>
          </td>
        </tr>
        <tr>
          <td valign="Bottom" align="Left">
            <div class="logo">
              <a href="https://link2.com/">
                <img src="logo.png" width="257" height="95">
              </a>
            </div>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</body>

<!-- end snippet -->

我是您的中文翻译,只提供翻译,不包含其他内容。

英文:

I'm unsure why the link for the first image in the table is messed up since it has the same structure as the second image which does work fine, it's just in a different location. I've copied the relevant sections of html below as block code

I'm new to html but have been able to make everything else work fine. Any help would be appreciated!

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

#webpage {

width: 1000px ;

margin-left: auto ;

margin-right: auto ;

}



/* Pennant pos */

.pennant {

padding: 0px 0px;

position: absolute;

}



/* Logo pos */

.logo {

padding: 300px 0px;

position: absolute;

}

<!-- language: lang-html -->

&lt;body style=&quot;color:white&quot;&gt;

  &lt;div id=&quot;webpage&quot;&gt;

  &lt;hr id=&quot;home&quot;&gt;

  &lt;br&gt;

&lt;table width=&quot;100%&quot; border=&quot;0&quot;&gt;

  &lt;tbody&gt;

    &lt;tr&gt;

      &lt;td valign=&quot;Top&quot; align=&quot;Left&quot;&gt;

        &lt;div class=&quot;pennant&quot;&gt;

          &lt;a href=&quot;https://link1.com/&quot;&gt;

             &lt;img src=&quot;pennant.png&quot; width=&quot;350&quot; height=&quot;226&quot;&gt;
          &lt;/a&gt;

        &lt;/div&gt;

      &lt;/td&gt;

    &lt;/tr&gt;

    &lt;tr&gt;

      &lt;td valign=&quot;Bottom&quot; align=&quot;Left&quot;&gt;

        &lt;div class=&quot;logo&quot;&gt;

          &lt;a href=&quot;https://link2.com/&quot;&gt;

            &lt;img src=&quot;logo.png&quot; width=&quot;257&quot; height=&quot;95&quot;&gt;

          &lt;/a&gt;

        &lt;/div&gt;

      &lt;/td&gt;

    &lt;/tr&gt;

  &lt;/tbody&gt;

&lt;/table&gt;

&lt;/div&gt;

&lt;/body&gt;

<!-- end snippet -->

答案1

得分: 1

".pennant { padding: 0px 0px; }" 应该是:".pennant { padding: 0px 0px; }"

英文:

I am not sure but position of .pennant cannot be absolute, it moves the div into the other place than your image is, try removing it.


.pennant {

  padding: 0px 0px;

}

huangapple
  • 本文由 发表于 2023年5月18日 00:42:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274385.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定