如何在jQuery的hover()事件的热点中包含元素的margin? [英] How do I include an element's margin in the hot-spot for jQuery's hover() event?
本文介绍了如何在jQuery的hover()事件的热点中包含元素的margin?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery(".my_container").hover(function(){
//do code
}, function(){
//do code
});
.my_container { width: 100px; height: 100px; margin: 50px; }
上述代码不会对鼠标悬停余量
The code above doesn't react to mouse over of margin (margin isn't a part of element?) - how can I change that?
推荐答案
也许使用第二个包装器元素在外部元素和现有的背景和内部元素上的填充样式:
Perhaps use a 2nd wrapper element with padding on the outer element and existing background and padding styles on the inner element:
<div class="my_container">
<div class="my_container_inner">
<!-- etc. -->
</div>
</div>
jQuery(".my_container").hover(function(){
//do code
}, function(){
//do code
});
.my_container { padding: 50px; }
.my_container_inner { width: 100px; height: 100px; /* etc. */ }
这篇关于如何在jQuery的hover()事件的热点中包含元素的margin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文