首页 > 解决方案 > 工具提示容器正在显示地下项目

问题描述

我有一个带有一些问题的 HTML 表单和一个选择标签作为答案。我想用工具提示来解释这些答案。

HTML

<div id="domanda">
<div class="help-tip">
<p> some text</p></div>
This is the question:
</div><div id="scelte">
<select name="finalita">
<option value="1">Answer 1</option> 
<option value="2">Answer 2</option>
</select></div>

CSS

#domanda{
font-size: 18px;
}
#scelte{
margin-bottom: 30px;
}

.help-tip{
display: inline-block;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: pointer;
}

.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}

.help-tip:hover p{
display: block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}

.help-tip p{    /* The tooltip */
display: none;
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 800px;
position: right;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 15px;
line-height: 1.4;
}

.help-tip p:before{ /* The pointer of the tooltip */
display: none;
}    

.help-tip p:after{ /* Prevents the tooltip from being hidden */
width:100%;
height:40px;
content:'';
position: absolute;
top:-40px;
left:0;
}

/* CSS animation */

@-webkit-keyframes fadeIn {
0% { 
    opacity:0; 
    transform: scale(0.6);
}

100% {
    opacity:100%;
    transform: scale(1);
}
}

@keyframes fadeIn {
0% { opacity:0; }
100% { opacity:100%; }
}

问题是它还显示了工具提示段落下的内容,如您在此处看到的 在此处输入图像描述

这是鼠标没有悬停时的图片 在此处输入图像描述

我花了一段时间试图修复它,但没有成功。我的css有什么问题?

标签: htmlcsstooltip

解决方案


添加position: relative;.help-tip:hover p修复它。感谢 vssadineni


推荐阅读