Jquery 使用 jquery ui 对话框悬停动画
Jquery hover animate with jquery ui dialog
我有一个小而奇怪的问题,我的动画是用 jquery 和 jquery UI 实现的。您可以在下面看到一个简单的工作演示,
当您尝试单击窗帘中的 "Click me",然后在显示的弹出窗口中单击 "Close" 时,问题就出现了。你会看到窗帘和图像都升起。你知道为什么吗?
非常感谢
$(document).ready(function () {
$('.box_product_image').hover(function () {
$('.box_up-down', this).stop().animate({
bottom: '0px'
}, 300);
$('.box_product_arrow', this).fadeOut(300);
}, function () {
$('.box_up-down', this).stop().animate({
bottom: '-96px'
}, 600);
$('.box_product_arrow', this).fadeIn(300);
});
$(document).on('click', '#text', function () {
$("#dialog").dialog({
height: 200,
width: 200,
modal: true,
closeText: "close"
});
});
});
*, ul, ol {
border: 0 none;
margin: 0;
padding: 0;
}
.box_product_border_image {
border: 1px solid #d9d9d9;
border-radius: 6px;
height: 120px;
overflow: hidden;
width: 150px;
margin: 50px;
}
.box_product_image {
float: left;
height: 120px;
overflow: hidden;
position: relative;
}
.box_up-down {
background-color: rgba(0, 0, 0, 0.8);
bottom: -96px;
height: 100%;
left: 0;
position: absolute;
width: 150px;
}
.box_up-down > * {
color: #fff;
font-size: 11px;
}
.box_product_name {
font-weight: bold;
margin: 3px 0 0 10px;
}
.box_product_arrow {
height: 19px;
position: absolute;
right: 15px;
top: 3px;
width: 10px;
}
.box_product_desc {
margin: 5px 0 0 10px;
}
.box_product_desc ul {
font-size: 10px;
line-height: 10px;
list-style-type: none;
}
.box_product_desc ul li {
margin-bottom: 6px;
}
.box_product_desc ul li a {
color: #fff;
text-decoration: none;
}
#dialog {
background-color: rgba(0,0,0,0.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js" type="text/javascript"></script>
<div class="box_product_border_image">
<div class="box_product_image">
<img width="150" height="120" src="http://www.microproject.com/wp-content/themes/NybergsMekVerstand/images/img03.png">
<div class="box_up-down">
<div class="box_product_name">Text</div>
<div class="box_product_arrow" style="display: block;">
<img width="10" height="19" title="" alt="" src="http://tpgroupindia.com/images/arrow.png">
</div>
<div class="box_product_desc">
<ul>
<li>
<a href="#">Text</a>
</li>
<li>
<a href="#">Text</a>
</li>
<li>
<a id="text" href="#">Click me</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="dialog"></div>
我稍微重写了你的代码(jQuery、HTML和css),看看fiddle。
万恶之源可能是因为 link 保持焦点..所以点击后可能需要模糊它。
http://jsfiddle.net/006L4uof/5/
$('#text').on('click', function(e){
$(this).blur(); //remove focus from clicked link
$('#dialog').dialog({
height: 200,
width: 200,
modal:true,
closeText:"close"
});
});
如果它没有按预期工作,请告诉我。
我有一个小而奇怪的问题,我的动画是用 jquery 和 jquery UI 实现的。您可以在下面看到一个简单的工作演示,
当您尝试单击窗帘中的 "Click me",然后在显示的弹出窗口中单击 "Close" 时,问题就出现了。你会看到窗帘和图像都升起。你知道为什么吗?
非常感谢
$(document).ready(function () {
$('.box_product_image').hover(function () {
$('.box_up-down', this).stop().animate({
bottom: '0px'
}, 300);
$('.box_product_arrow', this).fadeOut(300);
}, function () {
$('.box_up-down', this).stop().animate({
bottom: '-96px'
}, 600);
$('.box_product_arrow', this).fadeIn(300);
});
$(document).on('click', '#text', function () {
$("#dialog").dialog({
height: 200,
width: 200,
modal: true,
closeText: "close"
});
});
});
*, ul, ol {
border: 0 none;
margin: 0;
padding: 0;
}
.box_product_border_image {
border: 1px solid #d9d9d9;
border-radius: 6px;
height: 120px;
overflow: hidden;
width: 150px;
margin: 50px;
}
.box_product_image {
float: left;
height: 120px;
overflow: hidden;
position: relative;
}
.box_up-down {
background-color: rgba(0, 0, 0, 0.8);
bottom: -96px;
height: 100%;
left: 0;
position: absolute;
width: 150px;
}
.box_up-down > * {
color: #fff;
font-size: 11px;
}
.box_product_name {
font-weight: bold;
margin: 3px 0 0 10px;
}
.box_product_arrow {
height: 19px;
position: absolute;
right: 15px;
top: 3px;
width: 10px;
}
.box_product_desc {
margin: 5px 0 0 10px;
}
.box_product_desc ul {
font-size: 10px;
line-height: 10px;
list-style-type: none;
}
.box_product_desc ul li {
margin-bottom: 6px;
}
.box_product_desc ul li a {
color: #fff;
text-decoration: none;
}
#dialog {
background-color: rgba(0,0,0,0.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js" type="text/javascript"></script>
<div class="box_product_border_image">
<div class="box_product_image">
<img width="150" height="120" src="http://www.microproject.com/wp-content/themes/NybergsMekVerstand/images/img03.png">
<div class="box_up-down">
<div class="box_product_name">Text</div>
<div class="box_product_arrow" style="display: block;">
<img width="10" height="19" title="" alt="" src="http://tpgroupindia.com/images/arrow.png">
</div>
<div class="box_product_desc">
<ul>
<li>
<a href="#">Text</a>
</li>
<li>
<a href="#">Text</a>
</li>
<li>
<a id="text" href="#">Click me</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="dialog"></div>
我稍微重写了你的代码(jQuery、HTML和css),看看fiddle。 万恶之源可能是因为 link 保持焦点..所以点击后可能需要模糊它。
http://jsfiddle.net/006L4uof/5/
$('#text').on('click', function(e){
$(this).blur(); //remove focus from clicked link
$('#dialog').dialog({
height: 200,
width: 200,
modal:true,
closeText:"close"
});
});
如果它没有按预期工作,请告诉我。