【问题标题】:How to put "a href link" into a <div>?如何将“a href 链接”放入 <div>?
【发布时间】:2017-04-27 22:16:05
【问题描述】:
<div id='machineanimation' style='float:right;background:none !important; margin-right:36px;'>
  <a href="onet.pl">
    <img src='./pix/foto0.png' alt='' />
  </a>
  <img src='./pix/foto1.png' alt='' />
  <img src='./pix/foto2.png' alt='' />

</div>

我看到了一些主题,但我不明白该怎么做。我想点击照片,然后它会将我的网站更改为其他网站,但我无法做到这一点

【问题讨论】:

  • 想解释更多?
  • 你只有一个 html 块。我们真的不知道你想做什么。不管你是初学者,你仍然需要解释你遇到的问题。
  • 可能你的href值有错误,试试&lt;a href="http://onet.pl"&gt;,但我不确定,因为你没有解释你的问题
  • 您的链接可能已损坏。否则,您的代码似乎是正确的。

标签: html image


【解决方案1】:

好的,我想我明白你想要什么了。似乎您希望图像成为超链接。您的代码应该可以工作,因此如果图像显示,您的问题必须在于 href 属性。如果图像未显示,请尝试检查 src 属性。尝试将href更改为google,只是为了测试。我整理了一个小提琴来演示你的代码工作:here

<div id='machineanimation' style='float:right;background:none !important; margin-right:36px;'>
    <a href="onet.pl">
        <img src='https://www.123freevectors.com/wp-content/uploads/new/icon/075-smiley-face-vector-art-free-download-l.png' alt='' />
    </a>
    <img src='./pix/foto1.png' alt='' />
    <img src='./pix/foto2.png' alt='' />
    <img src='./pix/foto3.png' alt='' />
    <img src='./pix/foto4.png' alt='' />
</div>

如您所见,我所做的只是修改图像源。

因为它适用于不同的图像,所以故障最有可能在于图像的 src 属性。检查它以确认它是正确的。

注意:

不建议使用内联样式。

【讨论】:

    猜你喜欢
    • 2012-06-18
    • 1970-01-01
    • 1970-01-01
    • 2018-06-15
    • 1970-01-01
    • 2014-06-10
    • 2021-09-15
    • 2010-09-21
    • 2012-03-14
    相关资源
    最近更新 更多