【问题标题】:Hyperlinked button images not working HTML超链接按钮图像无法使用 HTML
【发布时间】:2015-10-04 17:00:12
【问题描述】:

所以,我有一个包含 3 个超链接图像的表格,所有这些图像都在单击时将您带到目的地,但底部的 2 个 实际上并没有显示正确的图像 ,在你说“你没有一个叫这个的图像”之前,我已经检查了很多次。这是我的以下代码:

<table border=1 align=center>
  <tr>
    <th>More Help</th>
  </tr>
  <tr>
    <td>
      <a target="_blank" href="http//:www.w3schools.com">
        <input type="image" id="W3Schools" position:absolute style="height:100px; width:150px;" src="./Images/W3SchoolsButton.PNG">
      </a>
    </td>
  </tr>

  <!--This is repeated 2 times but just changing the src and href.-->

这只是第一个,已重复但我更改了 HREF 和 SRC,结果是第一个与图像一起使用,但最后两个提出了典型的图像剪贴画和单词'提交'

救命!

【问题讨论】:

  • HTML 禁止在锚点内输入元素。图像输入用于将点击的坐标发送到服务器,在这里没有任何意义。只需使用常规图像。 &lt;a href="..."&gt;&lt;img src="..." alt="..."&gt;&lt;/a&gt;
  • 我检查了多次 — 您是否通过查看开发人员工具的“网络”选项卡并确认您在页面上没有收到任何 404 错误进行检查?
  • 您为什么不尝试在此处的示例中将图像绝对路径传输到您的服务器? src="http://yourdomain.com/Images/W3SchoolsButton.PNG" - 这将明确表明图像存在于您认为的位置。
  • 昆汀,我刚刚摆脱了输入和 id。这不起作用,只会使情况变得更糟。现在,它不是按钮,而是目的地的字符串链接。斯图尔特,我也试过这个,它确实有效。

标签: html image button href src


【解决方案1】:

为什么在a 中使用input 标签?只需使用img 标签。

href 无效;它应该是http://www.w3schools.com,在双斜杠之前有冒号。

position: absolute 应该进入样式标签。

图片来源是否正确?相对于这个文件,图片文件夹是在同一个文件夹还是上一个文件夹?

这是你的固定代码:

<a target="_blank" href="http://www.w3schools.com">
    <img id="W3Schools"  style="height:100px; width:150px; position:absolute;" src="Images/W3SchoolsButton.PNG"> <-- for in the same folder
</a>

<a target="_blank" href="http://www.w3schools.com">
    <img id="W3Schools"  style="height:100px; width:150px; position:absolute;" src="../Images/W3SchoolsButton.PNG"> <-- for up one folder
</a>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-02
    • 2016-02-16
    • 1970-01-01
    • 2017-03-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-26
    相关资源
    最近更新 更多