制作<按钮>这是 HTML 中的链接 [英] Making a <button> that's a link in HTML

查看:16
本文介绍了制作<按钮>这是 HTML 中的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我喜欢 <input type="submit"> 的样式,当您添加一些 CSS 时带有可点击的按钮.但是,常规按钮没有这样的样式,如果没有一些主要的 CSS 或 JS,它们就没有这种可点击性,并且您必须使用图像.

Basically, I like the way that <input type="submit"> is styled, with the clickable button when you add a little CSS. However, regular buttons are not styled as such, they have no such clickability without some major CSS or JS, and you have to use images.

我通过使用表单操作将提交按钮制作成链接,但这需要我为每个按钮制作一个新表单.我怎样才能找到一个快乐的媒介?使用多个表单会导致我的样式出现问题,我似乎无法解决这些问题,除非我找到另一种方法来制作 HTML 中的链接按钮,该按钮具有默认样式,使它们具有按下状态(我不是说浏览器默认设置).

I made submit buttons into links, by using the form action, but this requires me to make a new form for each button. How can I find a happy medium? Using multiple forms is causing problems in my styling that I can't seem to fix unless I find another way to make buttons that are links in HTML, that have a default style that makes them have a pressed state (and I don't mean browser default settings).

有什么想法吗?

推荐答案

<a href="#"><button>Link Text</button></a>

您需要一个看起来像按钮的链接,所以使用一个链接和一个按钮 :-) 这将保留默认浏览器按钮样式.按钮本身什么都不做,但点击它会激活它的父链接.

You asked for a link that looks like a button, so use a link and a button :-) This will preserve default browser button styling. The button by itself does nothing, but clicking it activates its parent link.

演示:

<a href="http://stackoverflow.com"><button>Link Text</button></a>

这篇关于制作&lt;按钮&gt;这是 HTML 中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆