【问题标题】:disable prettyphoto on small screens (or any a href link)在小屏幕上禁用 prettyphoto(或任何 href 链接)
【发布时间】:2015-04-23 19:48:19
【问题描述】:

我一直在寻找一种在移动设备或任何其他小屏幕上禁用 prettyphoto 灯箱的方法,在尝试不同的脚本花了几个小时后,我发现了一种非常简单的方法来使用 css 媒体查询来做到这一点:

html

<div>
    <a class="lightbox" rel="prettyPhoto" href="img.jpg">
        <img src="img.jpg">
    </a>
</div>

css

@media all and (max-width: 479px) {
    a.lightbox {    
        pointer-events: none;
    }
}

但是,我只是想知道是否有更好的(正确的?)方法?使用 JS 函数 ( ($(window).width() ) 更好吗?我想确保它可以在任何设备上运行。谢谢。

【问题讨论】:

    标签: css media-queries href lightbox prettyphoto


    【解决方案1】:

    只需将其包装起来:

    if ($(window).width() >= 768) { 
        $("a[rel^='prettyPhoto']").prettyPhoto(); 
    }
    

    会起作用

    【讨论】:

    • 非常感谢您的回答:)
    猜你喜欢
    • 2014-02-14
    • 2011-07-19
    • 1970-01-01
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多