gpt4 book ai didi

javascript - 样式表干扰

转载 作者:太空宇宙 更新时间:2023-11-04 01:10:52 24 4
gpt4 key购买 nike

我遇到了一个小问题。我想显示 3 个房屋,当您将鼠标悬停在它们上方时,它会显示工具提示文本。这是我到目前为止得到的。如您所见,它运行良好,但是在添加样式表时它会干扰并删除房屋和工具提示文本:

<!DOCTYPE html>
<html>
<head>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
</head>
<style>
.tooltip {
position: relative;
display: inline-block;
}

.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;
top: 110%;
left: 50%;
margin-left: -60px;

/* Fade in tooltip - takes 1 second to go from 0% to 100% opac: */
opacity: 0;
transition: opacity 1s;


}

.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}

.tooltip:hover .tooltiptext {

visibility: visible;
opacity: 1;
}

.linkhome {
display: inline-block;
font-size: 2.25rem;
padding-left: 10px;
padding-right: 10px;

}

.linkhome :hover {
color:#23739b;
transition: color 0.3s ease-in-out;
}

.links {

}
</style>
<body>

<h2>Bottom Tooltip w/ Top Arrow</h2>
<div class="links">

<div class="tooltip"><div class="linkhome">
<a href="https://bitcoin.org/" target="_blank" title="Official website">
<i class="fas fa-home"></i>
</a>
</div>
<span class="tooltiptext">Homepage</span>
</div>
<div class="tooltip"><div class="linkhome">
<a href="https://bitcoin.org/" target="_blank" title="Official website">
<i class="fas fa-home"></i>
</a>
</div>
<span class="tooltiptext">Tooltip text</span>
</div>
<div class="tooltip"><div class="linkhome">
<a href="https://bitcoin.org/" target="_blank" title="Official website">
<i class="fas fa-home"></i>
</a>
</div>
<span class="tooltiptext">Tooltip text</span>
</div>
</div>



</body>
</html>

但是当我在 head-tag 中添加这个时:

<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css"
integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy"
crossorigin="anonymous">

带工具带的房子消失了,有什么理由解决这个问题吗?

感谢阅读这篇文章,希望有人能帮助我或给我建议。

最佳答案

我建议你使用 bootstrap4 工具提示

请尝试以下解决方案。

<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js">
</script>
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>

</head>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<body>
<h2>Bottom Tooltip w/ Top Arrow</h2>
<a href="https://bitcoin.org/" target="_blank" data-placement="bottom" data-toggle="tooltip" title="Official website">
<i class="fas fa-home"></i>
</a>
<a href="https://bitcoin.org/" target="_blank" data-placement="bottom" data-toggle="tooltip" title="Official website">
<i class="fas fa-home"></i>
</a>
<a href="https://bitcoin.org/" target="_blank" data-placement="bottom" data-toggle="tooltip" title="Official website">
<i class="fas fa-home"></i>
</a>
</body>
</html>

关于javascript - 样式表干扰,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51225838/

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