使用图像作为背景并使用href的html按钮的良好实践

使用图像作为背景并使用href的html按钮的良好实践,html,css,Html,Css,我一直在读如何实现一个按钮。有很多答案 没有人讨论为什么一个特定版本比另一个更受欢迎。今天的标准良好实践方式是什么 我特别寻找的按钮是一个没有文本的图像,使用href并且必须提交 我提出了以下建议,但不起作用: <button class="btn-googleplus" href="/auth/google" type="submit"></button> <input type="submit" class="btn-googleplus" /> bu

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

没有人讨论为什么一个特定版本比另一个更受欢迎。今天的标准良好实践方式是什么

我特别寻找的按钮是一个没有文本的图像,使用href并且必须提交

我提出了以下建议,但不起作用:

<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;
}
将href添加到按钮将不起作用。您需要将按钮放在一个表单中,在该表单中,您可以在action属性的url中指定href值

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

按钮类型提交将表单数据提交到被调用的表单操作!那么你需要提供href链接吗?按钮里面也有吗?使用锚定或按钮类型提交!Coz href inside是无效的标记。或者干脆去玩onclick;对于样式,请使用背景图像并旋转边框:0删除按钮和.btn googleplus之间的空格。@Paulie_D+1最后一个很好的解释。我不敢相信这些年来我错过了链接vs按钮。
<form action="/auth/google">
    <button href="/auth/google" type="submit">
        <img id="img" src="img/googleplus.png" />
    </button>
</form>