【发布时间】:2019-07-29 20:37:53
【问题描述】:
我想在我的导航栏上使用一个图标作为下拉按钮,但我是 html 和其他东西的新手,所以我不知道我的 snipplet 失败的地方:
<button type= "image" class="dropbtn" onclick="myFunction()">
<img src="someimage.png" title="Some title">
</button>
【问题讨论】:
我想在我的导航栏上使用一个图标作为下拉按钮,但我是 html 和其他东西的新手,所以我不知道我的 snipplet 失败的地方:
<button type= "image" class="dropbtn" onclick="myFunction()">
<img src="someimage.png" title="Some title">
</button>
【问题讨论】:
在您的情况下,问题很可能与图像的来源有关。检查路径(图像所在的位置)并正确链接。
示例:src="../folder/folder/image.png"
您还可以使用 CSS 将图像添加为背景,如下所示:
.dropbtn {
background: url("");
}
【讨论】:
我认为问题在于您正在使用按钮。 试试这个:
<a href="" class="dropbtn" onclick="myFunction()">
<img src="someimage.png" title="Some title">
</a>
【讨论】: