首页 > 解决方案 > 我试图让我的按钮可点击,所以我有一个使用 h ref 和 button 元素的网站链接

问题描述

我希望我的按钮链接到我创建的实际网站:例如 Joeys Auto

我的投资组合网站是:http : //loriroberg.com/cssfinalproject/index.html#home 它有一个 JOEYS AUTO 按钮。Joeys Auto 的网站是http://loriroberg.com/final/index.html

如何更改此代码:

<div class="w3-col m3"><button class="button4 w3-button w3-padding-large w3-light-grey" style="margin-top:64px">Joeys Auto</button></div>

所以它会链接到JOEYS AUTO?

以下代码位于我的投资组合的 MY PROJECTS 部分下。

<h3 class="w3-center">MY PROJECTS</h3>

<p class="w3-center"><em>Here are some of the projects I completed.<br />
I will post more soon.<br />
Click on the links to view them on the web.</em></p>
<br />
<!-- Responsive Grid. Four columns on tablets, laptops and desktops. Will stack on mobile devices/small screens (100% width) -->
<div class="w3-row-padding w3-center">


<div class="w3-col m3"><button class="button4 w3-button w3-padding-large w3-light-grey" style="margin-top:64px">Joeys Auto</button></div>

<div class="w3-col m3"><button class="button4 w3-button w3-padding-large w3-light-grey" style="margin-top:64px">CSS3 2D Animation</button></div>


<div class="w3-col m3"><button class="button4 w3-button w3-padding-large w3-light-grey" style="margin-top:64px">CSS3 Animation</button></div>

<div class="w3-col m3"><button class="button4 w3-button w3-padding-large w3-light-grey" style="margin-top:64px">CSS3 3D Animation</button></div>
<!--<button class="w3-button w3-padding-large w3-light-grey" style="margin-top:64px">LOAD MORE</button>  

标签: htmlbuttonhyperlinkhref

解决方案


对于链接到其他网站(例如从您的投资组合链接到外部网站),您需要使用HTML 锚标记。您可以使用以下链接:

<a href="http://example.com">Joey's Auto</a>

如果您已经在 loriroberg.com,您还可以使用相对 URL:

<a href="/final/index.html">Joey's Auto</a>

这将带你到http://loriroberg.com/final/index.html. 您可以在此 StackOverflow 问题中找到有关相对 URL 与绝对 URL 的更多信息


推荐阅读