简体   繁体   English

如何在iOS上使灯箱滚动?

[英]How can I make a lightbox scrollable on iOS?

I know that this problem was discussed many times here, but I did not find an answer to really help me. 我知道这个问题在这里已经讨论了很多次,但是我没有找到真正帮助我的答案。

I have a lightbox with is code: 我有一个灯箱,代码是:

Html HTML

<div class="overlay-background">
 <div class="overlay-content">
   <object type="text/html" data="https://en.wikipedia.org/wiki/Dentist" style="width: 100%; height: 100%;" </object>
</div>

CSS CSS

.noscroll {
      overflow: hidden;
      overflow-y: hidden;
      height: 100%;
    }

.scroll {
  overflow: scroll;
  -webkit-overflow-scrolling: touch;
}
.overlay-background {
            display: block;
            position: absolute;
            top: 0;
            left: 0;
            height:100vh;
            width: 100vw;
            z-index: 1000; /* high z-index */
            background: #000; /* fallback */
            background: rgba(33, 72, 144, .8);
        }

.overlay-content 
        {
            display: block;
            background: rgba(33, 72, 144, .9);
            width: 95vw;
            height: 80vh;
            position: absolute;
            top: 10vh;
            left: 2.5vw;
            margin: 0 0 0 0;
            cursor: default;
            z-index: 1001;
            box-shadow: 0 0 5px rgba(33, 72, 144, .7);
        }

And JS: 和JS:

//Declare vars
var $lightboxAnchor = $("a.list_message");

//Lightbox
$(".overlay-background").hide();

///--------------------------------------
//Lightbox
//--------------------------------------

$(".overlay-background").hide();

//Lightbox functions from leistungen

$lightboxAnchor.click(function(){
    var $attr = $(this).attr("href").replace("#", "");
    console.log($attr);
    $('div[id=' + $attr + ']').show();
    $("body").addClass("noscroll");
    $("html").addClass("noscroll");
    $(".overlay-content").addClass("scroll");
});

//Lightbox overlay

$(".overlay-background").click(function(){
    console.log('alert');
    $(this).hide();
    $("body").removeClass("noscroll");
    $("html").removeClass("noscroll");
    $(".overlay-content").removeClass("scroll");
});

And everything works perfectly except for the iOS devices, on Safari where my lightbox is not scrolling at all. 除了iOS设备(在我的灯箱根本不滚动的Safari上)之外,所有其他设备都可以正常运行。

I have tested on Mac devices on Safari and it works. 我已经在Safari的Mac设备上进行了测试,并且可以正常工作。 Can you please help me, it`s very important for me to fix this issue. 您能帮我吗,解决这个问题对我来说非常重要。

Thank you very much! 非常感谢你!

Here is a JSfiddle, with the code: https://jsfiddle.net/9mesun50/1/ 这是一个JSfiddle,其代码为: https ://jsfiddle.net/9mesun50/1/

I have found a solution to my problem, instead of using the "object" tag: 我找到了解决问题的方法,而不是使用“ object”标签:

<object type="text/html" data="https://en.wikipedia.org/wiki/Dentist" style="width: 100%; height: 100%;" </object>

I used the iframe tag. 我使用了iframe广告代码。 It works ok. 可以。

iframe src="https://en.wikipedia.org/wiki/Dentist" width: 100%; height: 100%;></iframe>

Here is an example: 这是一个例子:

https://jsfiddle.net/9mesun50/2/ https://jsfiddle.net/9mesun50/2/

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

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