我在尝试为网页上的“后端”按钮创建工具提示时遇到问题。工具提示效果没有出现在按钮上,我无法弄清楚原因。
这是我正在使用的代码:
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/style/interface1.css">
<title>interface</title>
<style>
/* Styles for the "Back-end" button */
.back-end_link{
display: flex;
}
.back-end_link button{
background-color: rgba(0, 0, 0, 0.993);
color: aliceblue;
border: transparent;
transition: 0.5s;
font-size: 30px;
box-shadow: inset 0 0 0 0 rgb(0, 0, 0);
}
.back-end_link button:hover{
border: none;
background-color: rgba(255, 255, 255, 0.949);
color: rgba(0, 0, 0, 0.485);
text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.373);
transform: scale(0.9);
letter-spacing: 3px;
box-shadow: inset 0 0 10px rgb(255, 255, 255), 0 0 40px rgb(255, 255, 255), 0 0 80px rgb(255, 255, 255);
}
.details-back-end{
color: #fff;
visibility: hidden;
opacity: 0;
}
.back-end_link:hover .details-back-end{
visibility: visible;
opacity: 1;
}
.details{
font-family: "Kanit", sans-serif;
display: flex;
position: absolute;
justify-content: center;
align-items: center;
width: 1100px;
color: aliceblue;
text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.575);
}
</style>
</head>
<body>
<div class="container">
<div class="login-registro">
<div class="login">
<button id="login-button">
<a href="login.html">
login
</a>
</button>
</div>
<div class="register">
<button class="register-button">
<a href="registro.html">
registre-se
</a>
</button>
</div>
</div><!--div login-registro-->
<div class="front-back">
<div class="front-end_link">
<a href="#">
<button>
FRONT-END
</button>
</a>
</div>
<div class="back-end_link">
<a href="#">
<button>
BACK-END
</button>
</a>
</div>
</div><!--div front-back-->
<div class="details">
<p class="details-front-end">
DETAILS ABOUT FRONT-END
</p>
<p class="details-back-end">
DETAILS ABOUT BACK-END
</p>
</div>
</div>
</div>
</body>
</body>
</html>
我已经尝试了多种方法来解决该问题,但将鼠标悬停在“后端”按钮上时根本没有出现工具提示。
如果有人可以帮助我找出我做错了什么,我将不胜感激!
谢谢你。
据我从您的代码中看到,您希望在悬停 html 对象时有一个工具提示,在本例中是一个按钮。 此页面展示了一种在悬停时创建工具提示的非常简单的方法。
代码看起来像这样:
.tooltip {
margin-top: 50px;
position: relative;
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: black transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/style/interface1.css">
<title>interface</title>
</head>
<body>
<div class="tooltip">Hover over me
<span class="tooltiptext">Tooltip text</span>
</div>
</body>
</html>