移动 Safari 和 x 偏移

发布于 2024-11-03 08:39:01 字数 688 浏览 0 评论 0原文

我之前发布过(https://stackoverflow.com/questions/5737833/ adjustment- Horizo​​ntal-offset-for-an-image-gallery-in-mobile-safari) 关于使用 Javascript 查找 Mobile 中视口的 x 偏移Safari,然后将其作为基于 px 的值应用于元素的内联 CSS。

这篇文章有点啰嗦并且特定于该应用程序,因此我将在这里提出真正的问题:

是否有一种方法可以确定 Mobile Safari 中视口的 x 偏移,然后将其应用到元素,如下所示内联样式?

这将是必要的,不仅是为了正确放置图像库叠加层,而且也是为了在整个网站中使用命名锚点。据我了解,需要一些 JS 技巧,因为 Mobile Safari 不支持确定对象(或视口)的 x 偏移的常用方法。

I posted previously (https://stackoverflow.com/questions/5737833/adjusting-horizontal-offset-for-an-image-gallery-in-mobile-safari) about using Javascript to find the x-offset of a viewport in Mobile Safari and then apply that as a px-based value to an element's inline CSS.

The post was a little long-winded and specific to that application, so I'll ask the real question here:

Is there a way to determine the viewport's x-offset in Mobile Safari, and then apply it to an element as an inline style?

This will be necessary, not just to place the image gallery overlay properly, but also to use named anchors throughout the site. It's my understanding that some JS trickery is required, as Mobile Safari doesn't support the usual methods of determining the x-offset of an object (or the viewport).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼波传意 2024-11-10 08:39:01

我不太确定我是否理解你的问题,但在使用 jquery 的移动 safari(假设 Iphone、Ipod、Ipad)上的 javascript 中,我使用以下行将 z-index 的 div 层彼此重叠。 <代码>

var left1 = jQuery("div#Layout_Border_div").offset().left;
var top1 = jQuery("div#Layout_Border_div").offset().top;
jQuery("div#LayoutPage_Backward").
  css( { position: "absolute","left": (left1) + "px","top": (top1) + "px" } );

如果您能给我一些代码示例,我可以提供更多帮助。

I'm not exactly sure if I understand your question but in javascript on mobile safari (asuming Iphone,Ipod,Ipad) using jquery I use the following lines to position div layers with z-index on top of each other.

var left1 = jQuery("div#Layout_Border_div").offset().left;
var top1 = jQuery("div#Layout_Border_div").offset().top;
jQuery("div#LayoutPage_Backward").
  css( { position: "absolute","left": (left1) + "px","top": (top1) + "px" } );

if you can give me some sample of code I can help more.

ペ泪落弦音 2024-11-10 08:39:01

我设法想出了一个几乎解决方案:我将 marginLeft: window.pageXOffset + "px", 添加到 photoswipe.js 中定位包装器 div 的所有四个引用中。

现在,单击照片会导致照片查看器出现在视口内(如果它已滚动)。

然而,它并不理想:我手动编辑 photoswipe.js 源,首先,其次,图库实际上并不跟随用户的滚动(因此,当用户进一步向右滚动并单击另一个图像时,画廊出现在其第一个位置的位置)。

这已接近修复。如何使照片库动态跟随用户的滚动,最好不编辑 photoswipe.js 源代码?

I managed to come up with an almost-solution: I added marginLeft: window.pageXOffset + "px", to all four references of the positioned wrapper divs in photoswipe.js.

So now, clicking a photo results in the photo viewer appearing inside the viewport, if it's been scrolled at all.

However, it's not ideal: I'm manually editing photoswipe.js source, first of all, and second of all, the gallery doesn't actually follow the user's scroll (so, when the user scrolls further to the right and clicks another image, the gallery appears where its first position was).

This is close to being fixed. How can I make the photo gallery follow the user's scroll dynamically, preferably without editing photoswipe.js source code?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文