简体   繁体   English

jquery点击不使用css'position:fixed'属性

[英]jquery click not working with css 'position :fixed' property

When i am removing this property it is working fine, why is that so? 当我删除这个属性它工作正常,为什么会这样?

Here is the jquery function: 这是jquery函数:

 $(document).ready(function(){
 $('#flogo').click(function(){

   window.alert("clicked");

})
});

Here is Html code: 这是Html代码:

<div id="fblike" class="fixedlogo"><img src="images/likelogo.png" id="flogo" />    </div>

Here is css: 这是css:

 .fixedlogo
{
position: fixed; //If i remove this line then jquery is working.
height:50px;
margin-top: -20px;
}

This is likely an issue with z-index and not jQuery. 这可能是z-index而不是jQuery的问题。 jQuery wouldn't care what the position is set to. jQuery不关心这个位置是什么。 I suspect there is another element overlapping this one and blocking the click event. 我怀疑还有另一个元素与此重叠,并阻止了click事件。

将该位置设为具有可点击项目的div的相对位置。

position: relative;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM