Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I use a "position: absolute" in a div "position: relative". Is does not work. #61

Open
ZE3kr opened this issue Aug 2, 2014 · 1 comment

Comments

@ZE3kr
Copy link

ZE3kr commented Aug 2, 2014

Such as

<div style="position: relative;bottom: 5em;left: 2px;">
  <a href="http://ze3kr.com/video/2014/07/12/s1/#video" title="Play">
    <img src="http://ze3kr.com/image/play.png" style="position: absolute;width: 72px;height: 72px;" class="js-plaxify" data-xrange="20" data-yrange="20" />
  </a>
</div>
var layers = $('.js-plaxify')

$(document).ready(function () {
    $.plax.enable()
})

It's does not work. I find "inViewport" is wrong, When elements in the Viewport, it is not recognized. When I was at the top of the page (not the actual inViewport), but it is recognized inViewport.

And I Change the HTML like that

<div style="position: relative;bottom: 5em;left: 2px;" class="js-plaxify" data-xrange="20" data-yrange="20">
  <a href="http://ze3kr.com/video/2014/07/12/s1/#video" title="Play">
    <img src="http://ze3kr.com/image/play.png" style="position: absolute;width: 72px;height: 72px;"  />
  </a>
</div>

It still not work. But I find it Automatically add this

div .js-plaxify {
  left: 173px;
  top: 936px;
}

At last, I add this and at finally it works.

layer.obj.css('position', absolute);
@classicemi
Copy link

I guess it's because the inViewport function returns false. The parent Element's offsetHeight is 0 when the element contains only one child element and the child element's position is absolute.

I think the only way to solve this problem is giving the absolute positioned element a wrapper to expand the parent element's offsetHeight if we don't change the inViewport function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants