Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 悬停时隐藏工具提示?_Javascript_Html_Css_Tooltip_Jquery Ui Tooltip - Fatal编程技术网

Javascript 悬停时隐藏工具提示?

Javascript 悬停时隐藏工具提示?,javascript,html,css,tooltip,jquery-ui-tooltip,Javascript,Html,Css,Tooltip,Jquery Ui Tooltip,我们使用工具提示在颜色选择器上显示颜色名称。 您可以在此处看到结果: 不幸的是,工具提示并不能很好地工作 问题是,当光标位于颜色选择器的中间时,将光标移到 再加上一种颜色,工具提示不会消失 如果您将鼠标悬停在新颜色或工具提示上,我们需要找到隐藏工具提示的解决方案 。。。 我们尝试向上移动工具提示,因此颜色和工具提示之间有一点间隙。但是,如果你移动鼠标的速度更快,你就会捕捉到过渡效果 也许是一些JavaScript? /** Color Swatches **/ .swatch { f

我们使用工具提示在颜色选择器上显示颜色名称。

您可以在此处看到结果:

不幸的是,工具提示并不能很好地工作

问题是,当光标位于颜色选择器的中间时,将光标移到 再加上一种颜色,工具提示不会消失

如果您将鼠标悬停在新颜色或工具提示上,我们需要找到隐藏工具提示的解决方案

。。。 我们尝试向上移动工具提示,因此颜色和工具提示之间有一点间隙。但是,如果你移动鼠标的速度更快,你就会捕捉到过渡效果

也许是一些JavaScript?

/** Color Swatches **/ 


.swatch { 
  float: left;
  width: 100%;
  margin: 0px 0px 10px 0px;
}

.swatch .header {
  margin: 0.5em 0; 
}

.swatch input { 
  display:none;
}

.swatch label {
  width: 100%;
  height: 40px;
  float:left;
  margin:0;
}

.swatch-element label {
  cursor: pointer;
}

.swatch .swatch-element {
  width: 20%;
  height: 40px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;    
  box-sizing: border-box;        
  float:left;
  -webkit-transform:translateZ(0); 
  -webkit-font-smoothing:antialiased; 
  position:relative;
}

.swatch input:checked + label {
  text-align: center;
  width: 100%;
}


.swatch input:checked + label:before {
  font-family: 'icomoon';
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  content: "\e607";
  line-height: 40px;
  font-size: 15px;
  color: #fff;
  background: rgba(0,0,0,0.45);
  padding: 6px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  border-radius: 50%;   
}

.swatch .tooltip {
  font: normal 12px sans-serif;
  text-align:center;
  background: #27282b;
  color:#fff;
  bottom:100%;
  padding:  10px;
  display:block;
  position:absolute;
  width:140%;
  left: -20%;
  margin-bottom:15px;
  filter:alpha(opacity=0);
  -khtml-opacity: 0;
  -moz-opacity: 0;
  opacity:0;
  visibility:hidden;
  -webkit-transform: translateY(10px);
  -moz-transform: translateY(10px);
  -ms-transform: translateY(10px);
  -o-transform: translateY(10px);
  transform: translateY(10px);
  -webkit-transition: all .25s ease-out;
  -moz-transition: all .25s ease-out;
  -ms-transition: all .25s ease-out;
  -o-transition: all .25s ease-out;
  transition: all .25s ease-out;
  -webkit-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
  -moz-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
  -ms-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
  -o-box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.28);
  -webkit-border-radius: 3px;
  -moz-border-radius: 3px;
  border-radius: 3px;        
  z-index: 10000;
  -moz-box-sizing:border-box; 
  -webkit-box-sizing:border-box; 
  box-sizing:border-box;
}

.swatch .tooltip:before {
  bottom:-20px;
  content:" ";
  display:block;
  height:20px;
  left:0;
  position:absolute;
  width:100%;
}

.swatch .tooltip:after {
  border-left:solid transparent 10px;
  border-right:solid transparent 10px;
  border-top:solid #27282b 10px;
  bottom:-9px;
  content:" ";
  height:0;
  left:50%;
  margin-left:-13px;
  position:absolute;
  width:0;
}

.swatch .swatch-element:hover .tooltip {
  filter:alpha(opacity=100);
  -khtml-opacity:1;
  -moz-opacity:1;
  opacity:1;
  visibility:visible;
  -webkit-transform:translateY(0px);
  -moz-transform:translateY(0px);
  -ms-transform:translateY(0px);
  -o-transform:translateY(0px);
  transform:translateY(0px);
}


/** Color Swatches **/   

您可以将
指针事件:none
添加到
.swatch.tooltip

.swatch.tooltip{
...;
指针事件:无
}

我希望你能接受

对于IE浏览器,您可以通过以下方式解决缺少指针事件的问题:

.swatch.tooltip:hover{display:none}