我使用基于html css的http://tutorialzine.com/2014/07/css-inline-help-tips/创建了内联帮助提示。下面的代码适用于鼠标悬停在帮助图标上,它显示了一些文字但我需要的是自动显示鼠标悬停文本“hello pls help”鼠标悬停我需要鼠标悬停信息在页面加载后自动显示。提前感谢
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.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: 200px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.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%; }
}
<div class="help-tip">
<p id="helpinforchart">hello pls help</p>
</div>
答案 0 :(得分:2)
只需添加display:block代替display:none
.help-tip p
{
display:block;
}
答案 1 :(得分:2)
从css中删除display:none,如下所示
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.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 */
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 200px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.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%; }
}
<div class="help-tip">
<p id="helpinforchart">hello pls help</p>
</div>
答案 2 :(得分:1)
从
.help-tip:hover删除属性可以帮助您
.help-tip{
position: absolute;
top: 18px;
right: 18px;
text-align: center;
background-color: #BCDBEA;
border-radius: 50%;
width: 24px;
height: 24px;
font-size: 14px;
line-height: 26px;
cursor: default;
}
.help-tip:before{
content:'?';
font-weight: bold;
color:#fff;
}
.help-tip p{ /* The tooltip */
text-align: left;
background-color: #1E2021;
padding: 20px;
width: 200px;
position: absolute;
border-radius: 3px;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
right: -4px;
color: #FFF;
font-size: 13px;
line-height: 1.4;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p:before{ /* The pointer of the tooltip */
position: absolute;
content: '';
width:0;
height: 0;
border:6px solid transparent;
border-bottom-color:#1E2021;
right:10px;
top:-12px;
}
.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%; }
}
<div class="help-tip">
<p id="helpinforchart">hello pls help</p>
</div>
答案 3 :(得分:0)
hume
您可以更改css:
/* add 'active' class behavior */
.help-tip:hover p,
.help-tip.active p{
display:block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
并更改html,如:
<!-- add 'active' class -->
<div class="help-tip active">
<p id="helpinforchart">hello pls help</p>
</div>
如果您想将操作行为更改为&#39; hover show&#39;,请添加如下的js:
// native
var tip = document.getElementsByClassName('help-tip')[0];
tip.className = tip.className.replace('active', '');
// jQuery
$('.help-tip').removeClass('active')
答案 4 :(得分:0)
如果你愿意添加一些javascript这个jQuery代码和.display类保留悬停功能并在文档加载时显示工具提示:
的CSS:
.display {
display: block !important;
}
jQuery(加载在文档'&lt; head&gt;'):
$(window).load(function(){
$('#helpinforchart').addClass('display');
$('.help-tip').mouseleave(function(){
$('#helpinforchart').removeClass('display');
$(this).unbind();
})
});
要看到它的工作,请看这个小提琴:https://jsfiddle.net/r80o6ej8/