github充当服务器

Sometimes you may want to use a button to link to another page or website rather than to submit a form or something like that. This is fairly simple to do and can be achieved in several ways.

有时,您可能希望使用按钮链接到另一个页面或网站,而不是提交表单或类似内容。 这非常简单,可以通过多种方式实现。

One way is to simply wrap your <button> tag in an <a> tag:

一种方法是将<button>标记简单地包装在<a>标记中:

<a href='https://www.freecodecamp.org/'><button>Link To freeCodeCamp</button></a>

This transforms your entire button into a link.

这会将您的整个按钮转换为链接。

A second option is to create your link as you normally would with your <a> tag and then style it via CSS:

第二种方法是像通常使用<a>标记那样创建链接,然后通过CSS设置样式:

<a href='https://www.freecodecamp.org/'>Link To freeCodeCamp</a>

Once you’ve created your link, you can the use CSS to make it look like a button. For instance, you could add a border, a background color, some styles for when the user is hovering the link…

一旦创建了链接,就可以使用CSS使其看起来像一个按钮。 例如,您可以添加边框,背景色以及用户悬停链接时的某些样式…

Another way to add a button is to wrap an input inside form tags. Specify the desired target URL in the form action attribute.

添加按钮的另一种方法是将input包装在form标签中。 在表单操作属性中指定所需的目标URL。

<form action="http://google.com">
    <input type="submit" value="Go to Google" />
</form>
更多信息: (More Information:)

翻译自: https://www.freecodecamp.org/news/how-to-create-an-html-button-that-acts-like-a-link/

github充当服务器

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐