gpt4 book ai didi

javascript - 如何向按钮添加链接?

转载 作者:行者123 更新时间:2023-11-28 04:46:44 25 4
gpt4 key购买 nike

在任何人扑向我之前。我是网络管理员 (CCNP) IA/CND (CISSP) 类型。我这样说是为了让每个人都知道我来自哪里。这可能是最简单的问题,但是如何向下面列出的按钮添加 onclick 并使其转到...ancestry.com。我想我也会将其他按钮转到其他站点。建立我的第一个网站 Family Xmas gift 并边走边学。找到了一个模板网站,玩得很开心。

/* Try This*/
$(".hover").mouseleave(
function() {
$(this).removeClass("hover");
}
);
@import url(https://fonts.googleapis.com/css?family=Raleway:500);
.snip1564 {
background-color: #ffffff;
border: none;
border-bottom: 6px solid #029ebe;
border-top: 6px solid #029ebe;
color: #555;
cursor: pointer;
display: inline-block;
font-family: 'Raleway', Arial, sans-serif;
font-size: 14px;
font-weight: 500;
height: 46px;
letter-spacing: 3px;
line-height: 34px;
margin: 15px 40px;
outline: none;
padding: 0 10px;
position: relative;
text-transform: uppercase;
}
.snip1564:before,
.snip1564:after {
box-sizing: border-box;
-webkit-transition: all 0.3s;
transition: all 0.3s;
background-color: #ffffff;
border-radius: 50%;
top: -6px;
content: "";
height: 46px;
position: absolute;
width: 46px;
border: 6px solid #ddd;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
z-index: -1;
}
.snip1564:before {
right: -23px;
border-left-color: #029ebe;
border-bottom-color: #029ebe;
}
.snip1564:after {
left: -23px;
border-right-color: #029ebe;
border-top-color: #029ebe;
}
.snip1564:hover,
.snip1564.hover {
background-color: #ffffff;
}
.snip1564:hover:before,
.snip1564.hover:before,
.snip1564:hover:after,
.snip1564.hover:after {
-webkit-transform: rotate(225deg);
transform: rotate(225deg);
}
/* Try This*/

body {
background-color: #212121;
padding: 50px 0;
text-align: center;
}
<button class="snip1564">ancestry.com</button>
<button class="snip1564 hover">Facebook</button>
<button class="snip1564">Youtube</button>
<button class="snip1564">Send a happy Holidays greeting</button>

最佳答案

您可以通过两种方式做到这一点,制作一个看起来像按钮的超链接,或者制作一个带有更改页面的点击处理程序的按钮。

您将需要一些 CSS 来定义按钮的外观并将其分配给类

<a href='http://www.ancestry.com' class='button'>Ancestry</a>

<button class="snip1564" onclick='window.location="http://www.ancestry.com"'>
ancestry.com
</button>

编辑:这是一个 fiddle https://jsfiddle.net/qa0kco9b/1/

关于javascript - 如何向按钮添加链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40919189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com