HTML 锚元素有一个 'invisible' 按钮
HTML anchor element has an 'invisible' button
我创建了可点击的图标和将重定向到外部链接的按钮,但我刚刚注意到这些 'invisible' 按钮存在。我也知道这些可点击的空间是这些 icons/image 的原始位置,我已经使用“left: xx%”来重新定位它们但是我怎样才能让这个 'invisible' 按钮消失或者有更好的重新定位这些 icons/button?
的方法
invisible button 1
invisible button 2
invisible button 3
图标不可见,因为我使用的是外部样式表,我似乎无法包含它,但按钮是,在结果屏幕上按选项卡按钮会显示问题。
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css);
button {
color: #d4af37;
padding: 5px 25px;
border: 2px solid #d4af37;
position: relative;
margin: auto;
z-index: 1;
overflow: hidden;
transition: 0.3s;
}
button:after {
content: '';
background-color: #252526;
position: absolute;
z-index: -2;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
button:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0%;
height: 100%;
background-color: #d4af37;
transition: 0.3s;
z-index: -1;
}
button:hover {
cursor: pointer;
color: #252526;
}
button:hover:before {
width: 100%;
}
button:focus {
outline: none;
}
.contact {
font-size: 20px;
top: 0.8em;
left: 41.5%;
transform: translateY(20px);
transition: transform 1s, opacity 1s;
transition-delay: 0.7s;
}
.git {
color: white;
position: relative;
left: 13%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.git:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
.linked {
color: white;
position: relative;
left: 91.5%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.linked:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<br><br><br><br><br>
<a href=""><button type="button" id="contactbutton" class="contact animated">Let's Talk</button></a>
<div>
<div class="row" id="link-git">
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-linkedin linked" style="font-size: 35px;"></i></a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-github git" style="font-size: 35px;"></i></a>
</div>
</div>
</div>
</body>
首先,在 HTML5 中将 Button 标签嵌套在标签中是非法的。
发生此问题的原因是您将 css 左移并转换为按钮,但标签仍在其原始位置。
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css);
button, .abutton {
color: #d4af37;
padding: 5px 25px;
border: 2px solid #d4af37;
position: relative;
margin: auto;
z-index: 1;
overflow: hidden;
transition: 0.3s;
text-decoration: none;
}
button:after, .abutton:after {
content: '';
background-color: #252526;
position: absolute;
z-index: -2;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
button:before, .abutton:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0%;
height: 100%;
background-color: #d4af37;
transition: 0.3s;
z-index: -1;
}
button:hover, .abutton:hover {
cursor: pointer;
color: #252526;
}
button:hover:before, .abutton:hover:before {
width: 100%;
}
button:focus, .abutton:focus {
outline: none;
}
.contact {
font-size: 20px;
top: 0.8em;
left: 41.5%;
transform: translateY(20px);
transition: transform 1s, opacity 1s;
transition-delay: 0.7s;
}
.git {
color: white;
position: relative;
left: 13%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.git:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
.linked {
color: white;
position: relative;
left: 91.5%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.linked:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<br><br><br><br><br>
<a href=""><button type="button" id="contactbutton" class="contact animated">Let's Talk</button></a>
<a href="" type="button" id="contactbutton" class="abutton contact animated">Let's Talk</a>
<div>
<div class="row" id="link-git">
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-linkedin linked" style="font-size: 35px;"></i></a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-github git" style="font-size: 35px;"></i></a>
</div>
</div>
</div>
</body>
我创建了可点击的图标和将重定向到外部链接的按钮,但我刚刚注意到这些 'invisible' 按钮存在。我也知道这些可点击的空间是这些 icons/image 的原始位置,我已经使用“left: xx%”来重新定位它们但是我怎样才能让这个 'invisible' 按钮消失或者有更好的重新定位这些 icons/button?
的方法invisible button 1
invisible button 2
invisible button 3
图标不可见,因为我使用的是外部样式表,我似乎无法包含它,但按钮是,在结果屏幕上按选项卡按钮会显示问题。
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css);
button {
color: #d4af37;
padding: 5px 25px;
border: 2px solid #d4af37;
position: relative;
margin: auto;
z-index: 1;
overflow: hidden;
transition: 0.3s;
}
button:after {
content: '';
background-color: #252526;
position: absolute;
z-index: -2;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
button:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0%;
height: 100%;
background-color: #d4af37;
transition: 0.3s;
z-index: -1;
}
button:hover {
cursor: pointer;
color: #252526;
}
button:hover:before {
width: 100%;
}
button:focus {
outline: none;
}
.contact {
font-size: 20px;
top: 0.8em;
left: 41.5%;
transform: translateY(20px);
transition: transform 1s, opacity 1s;
transition-delay: 0.7s;
}
.git {
color: white;
position: relative;
left: 13%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.git:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
.linked {
color: white;
position: relative;
left: 91.5%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.linked:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<br><br><br><br><br>
<a href=""><button type="button" id="contactbutton" class="contact animated">Let's Talk</button></a>
<div>
<div class="row" id="link-git">
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-linkedin linked" style="font-size: 35px;"></i></a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-github git" style="font-size: 35px;"></i></a>
</div>
</div>
</div>
</body>
首先,在 HTML5 中将 Button 标签嵌套在标签中是非法的。
发生此问题的原因是您将 css 左移并转换为按钮,但标签仍在其原始位置。
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css);
button, .abutton {
color: #d4af37;
padding: 5px 25px;
border: 2px solid #d4af37;
position: relative;
margin: auto;
z-index: 1;
overflow: hidden;
transition: 0.3s;
text-decoration: none;
}
button:after, .abutton:after {
content: '';
background-color: #252526;
position: absolute;
z-index: -2;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
}
button:before, .abutton:before {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0%;
height: 100%;
background-color: #d4af37;
transition: 0.3s;
z-index: -1;
}
button:hover, .abutton:hover {
cursor: pointer;
color: #252526;
}
button:hover:before, .abutton:hover:before {
width: 100%;
}
button:focus, .abutton:focus {
outline: none;
}
.contact {
font-size: 20px;
top: 0.8em;
left: 41.5%;
transform: translateY(20px);
transition: transform 1s, opacity 1s;
transition-delay: 0.7s;
}
.git {
color: white;
position: relative;
left: 13%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.git:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
.linked {
color: white;
position: relative;
left: 91.5%;
transform: translateY(0);
transition: transform 0.5s;
padding-bottom: 5%;
}
.linked:hover {
cursor: pointer;
transform: translateY(-2.5px);
transition: transform 0.5s;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<br><br><br><br><br>
<a href=""><button type="button" id="contactbutton" class="contact animated">Let's Talk</button></a>
<a href="" type="button" id="contactbutton" class="abutton contact animated">Let's Talk</a>
<div>
<div class="row" id="link-git">
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-linkedin linked" style="font-size: 35px;"></i></a>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<a href="" target="_blank"><i class="fa fa-github git" style="font-size: 35px;"></i></a>
</div>
</div>
</div>
</body>