我一直在阅读如何实现按钮。有很多答案。

没有人讨论为什么要优先使用特定版本。今天的标准良好做法是什么?

我专门在寻找的按钮是image(无文本),使用href,必须为submit

我想出了以下方法,但是没有用:

<button class="btn-googleplus" href="/auth/google" type="submit"></button>

<input type="submit" class="btn-googleplus" />

button .btn-googleplus {
    background-image: url("img/googleplus.png") no-repeat center center;
}


我见过这样的变体(我不喜欢,因为在button标记中包含img似乎很复杂):

<button href="/auth/google" type="submit">
    <img id="img" src="img/googleplus.png" />
</button>

最佳答案

href添加到button将不起作用。您需要以一种在操作属性中指定href值(URL)的形式放置按钮。

<form action="/auth/google">
    <button href="/auth/google" type="submit">
        <img id="img" src="img/googleplus.png" />
    </button>
</form>

07-24 09:45
查看更多