点击内部div时,外部div隐藏 [英] Outer div is hiding when clicking on inner div
问题描述
我有客户网站 http://indiahomeplus.com/mapview.php
单击过滤器,然后选择一个查询,过滤器div隐藏。
它在Chrome中正常工作,但在firefox和IE中不起作用。
ul.ldd_menu {
margin :0px;
padding:0;
display:block;
height:50px;
background-color:#Ae2f2f;
list-style:none;
font-family:Trebuchet MS,sans-serif;
border-top:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
-moz-box-shadow:0px 3px 4px#591E12;
-webkit-box-shadow:0px 3px 4px#591E12;
-box-shadow:0px 3px 4px#591E12;
}
ul.ldd_menu a {
text-decoration:none;
}
ul.ldd_menu> li {
float:left;
position:relative;
}
ul.ldd_menu> li> span {
float:left;
color:#fff;
background-color:#ae2f2f;
height:50px;
line-height:50px;
cursor:default;
padding:0px 20px;
text-shadow:0px 0px 1px #fff;
border-right:1px solid #dddddd;
// border-left:1px solid#C44D37;
}
ul.ldd_menu .ldd_submenu {
position:absolute;
top:50px;
width:1000px;
height:360px;
display:none;
opacity:0.95;
left:0px;
font-size:10px;
background:#C34328;
border-top:1px solid #dddddd;
-moz-box-shadow:0px 3px 4px#591E12 inset;
-webkit-box-shadow:0px 3px 4px#591E12 inset;
-box-shadow:0px 3px 4px#591E12 inset;
z-index:99999;
}
a.ldd_subfoot {
background-color:#f0f0f0;
color:#444;
display:block;
clear:both;
padding:15px 20px;
text-transform:uppercase;
font-family:Arial,serif;
font-size:12px;
text-shadow:0px 0px 1px #fff;
-moz-box-shadow:0px 0px 2px#777 inset;
-webkit-box-shadow:0px 0px 2px#777 inset;
-box-shadow:0px 0px 2px#777 inset;
}
ul.ldd_menu ul {
list-style:none;
float:left;
border-left:1px solid#DF7B61;
margin:20px 0px 10px 30px;
padding:10px;
}
li.ldd_heading {
font-family:Georgia,serif;
font-size:13px;
font-style:italic;
color:#FFB39F;
text-shadow:0px 0px 1px#B03E23;
padding:0px 0px 10px 0px;
}
ul.ldd_menu ul li a {
font-family:Arial,serif;
font-size:10px;
line-height:20px;
color:#fff; $ b $ p padding:1px 3px;
}
ul.ldd_menu ul li a:hover {
-moz-box-shadow:0px 0px 2px#333;
-webkit-box-shadow:0px 0px 2px#333;
box-shadow:0px 0px 2px#333;
background:#AF412B;
}
这里是小提琴:
$ b b
$ b
因为鼠标轴的不完全实现 - 事件在浏览器jquery使用自己的实现,通过观察mouseover / mouseout。
在选择/选项中防止事件冒泡:
$ menu.children('li')。each(function(){
var $ this = $(this)
$ span = $ this.children('span');
$ span.data('width',$ span.width());
//防止事件从冒泡
$(this).find('select,option')
.on('mouseout mouseleave mouseover mouseenter',
function(e){
e.stopPagagation ();
return false;
});
$ this.on('mouseenter',function(){
$ menu.find('。ldd_submenu ')
//阻止$ this的子菜单隐藏
.not($('div',this))
.stop(true,true).hide
$ span.stop()。animate({
'width':'100px'
},300,function(){
$ this.find('。ldd_submenu' ).slideDown(300);
});
})。on('mouseleave',function(e){
$ this.find('。ldd_submenu')。stop(true,true).hide();
$ span .stop()。animate({
'width':$ span.data('width')+'px'
},300);
}
});
演示: http://jsfiddle.net/doktormolle/2e2br/
注意: strong>我向选择添加了一个小边距,否则菜单将不会消失,当你离开它通过左侧的选择。
i have client website http://indiahomeplus.com/mapview.php when clicking on filter and then selecting a query, the filter div is hiding. Its work fine in Chrome but not working in firefox and IE.
ul.ldd_menu{
margin:0px;
padding:0;
display:block;
height:50px;
background-color:#Ae2f2f;
list-style:none;
font-family:"Trebuchet MS", sans-serif;
border-top:1px solid #fff;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
-moz-box-shadow:0px 3px 4px #591E12;
-webkit-box-shadow:0px 3px 4px #591E12;
-box-shadow:0px 3px 4px #591E12;
}
ul.ldd_menu a{
text-decoration:none;
}
ul.ldd_menu > li{
float:left;
position:relative;
}
ul.ldd_menu > li > span {
float:left;
color:#fff;
background-color:#ae2f2f;
height:50px;
line-height:50px;
cursor:default;
padding:0px 20px;
text-shadow:0px 0px 1px #fff;
border-right:1px solid #dddddd;
//border-left:1px solid #C44D37;
}
ul.ldd_menu .ldd_submenu{
position:absolute;
top:50px;
width:1000px;
height: 360px;
display:none;
opacity:0.95;
left:0px;
font-size:10px;
background: #C34328;
border-top:1px solid #dddddd;
-moz-box-shadow:0px 3px 4px #591E12 inset;
-webkit-box-shadow:0px 3px 4px #591E12 inset;
-box-shadow:0px 3px 4px #591E12 inset;
z-index: 99999;
}
a.ldd_subfoot{
background-color:#f0f0f0;
color:#444;
display:block;
clear:both;
padding:15px 20px;
text-transform:uppercase;
font-family: Arial, serif;
font-size:12px;
text-shadow:0px 0px 1px #fff;
-moz-box-shadow:0px 0px 2px #777 inset;
-webkit-box-shadow:0px 0px 2px #777 inset;
-box-shadow:0px 0px 2px #777 inset;
}
ul.ldd_menu ul{
list-style:none;
float:left;
border-left:1px solid #DF7B61;
margin:20px 0px 10px 30px;
padding:10px;
}
li.ldd_heading{
font-family: Georgia, serif;
font-size: 13px;
font-style: italic;
color:#FFB39F;
text-shadow:0px 0px 1px #B03E23;
padding:0px 0px 10px 0px;
}
ul.ldd_menu ul li a{
font-family: Arial, serif;
font-size:10px;
line-height:20px;
color:#fff;
padding:1px 3px;
}
ul.ldd_menu ul li a:hover {
-moz-box-shadow: 0px 0px 2px #333;
-webkit-box-shadow: 0px 0px 2px #333;
box-shadow: 0px 0px 2px #333;
background: #AF412B;
}
here is the fiddle:
i.e working in chrome , but not in firefox and others.
Because of the incomplete implementation of the mouseleave-event in browsers jquery uses a own implementation by observing mouseover/mouseout. In contrast to the native mouseenter/mouseleave these events bubble, that's the reason for the issue.
Prevent the events from bubbling when they fire in select/option:
$menu.children('li').each(function () {
var $this = $(this),
$span = $this.children('span');
$span.data('width', $span.width());
//Prevent the events from bubbling
$(this).find('select,option')
.on('mouseout mouseleave mouseover mouseenter',
function (e) {
e.stopPropagation();
return false;
});
$this.on('mouseenter', function () {
$menu.find('.ldd_submenu')
//prevent the submenu of $this from hiding
.not($('div', this))
.stop(true, true).hide();
$span.stop().animate({
'width': '100px'
}, 300, function () {
$this.find('.ldd_submenu').slideDown(300);
});
}).on('mouseleave', function (e) {
$this.find('.ldd_submenu').stop(true, true).hide();
$span.stop().animate({
'width': $span.data('width') + 'px'
}, 300);
});
});
Demo: http://jsfiddle.net/doktormolle/2e2br/
Note: I've added a small margin-left to the select, otherwise the menu will not disappear when you leave it via the left side of the select.
这篇关于点击内部div时,外部div隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!