【问题标题】:Png image as html buttonpng 图像作为 html 按钮
【发布时间】:2019-07-29 20:37:53
【问题描述】:

我想在我的导航栏上使用一个图标作为下拉按钮,但我是 html 和其他东西的新手,所以我不知道我的 snipplet 失败的地方:

<button type= "image" class="dropbtn" onclick="myFunction()">
<img src="someimage.png" title="Some title">
</button>

【问题讨论】:

    标签: html image button png


    【解决方案1】:

    在您的情况下,问题很可能与图像的来源有关。检查路径(图像所在的位置)并正确链接。

    示例:src="../folder/folder/image.png"

    您还可以使用 CSS 将图像添加为背景,如下所示:

    .dropbtn {
      background: url("");
    }
    

    【讨论】:

    • 谢谢,在对我的 css 文件(在导航栏上)进行了一些修改后,它工作得很好。
    • 很高兴为您提供帮助 :) !
    【解决方案2】:

    我认为问题在于您正在使用按钮。 试试这个:

    <a href="" class="dropbtn" onclick="myFunction()">
        <img src="someimage.png" title="Some title">
    </a>
    

    【讨论】:

      猜你喜欢
      • 2018-07-22
      • 2021-06-01
      • 2021-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多