首页 \ 问答 \ 默认情况下隐藏叠加层时,jquery库不可见(jquery gallery not visible when overlay is hidden by default)

默认情况下隐藏叠加层时,jquery库不可见(jquery gallery not visible when overlay is hidden by default)

我有一个jquery库,它放在全屏绝对定位元素的内部,默认情况下,该元素用display: none隐藏,直到你单击一个按钮,然后该元素显示为jquery .show() 。 问题是,当我单击一个按钮时,会显示该全屏元素,但该元素(jquery库)中的所有内容都不可见。 仅显示全屏元素。 当我删除全屏元素的显示无(因此在加载时显示)时,可以看到图库(或内容)。 此外,在默认情况下隐藏它并且仅显示全屏元素而不显示内部元素(图库)的情况下,当我调整浏览器大小时,会显示图库?

演示: http//codepen.io/riogrande/pen/WxxjvJ

HTML

<div class="gallery">
    <div class="demo">
        <ul id="lightSlider">
            <li data-thumb="static/images/galerija/thumbs/15.jpg">
                <img src="static/images/galerija/15.jpg" alt="galerija"/>
            </li>
            <li data-thumb="static/images/galerija/thumbs/16.jpg">
                <img src="static/images/galerija/16.jpg" alt="galerija"/>
            </li>
            <li data-thumb="static/images/galerija/thumbs/17.jpg">
                <img src="static/images/galerija/17.jpg" alt="galerija"/>
            </li>
            <li data-thumb="static/images/galerija/thumbs/18.jpg">
                <img src="static/images/galerija/18.jpg" alt="galerija"/>
            </li>
        </ul>
    </div>
    <div class="close-gallery">
        <img src="static/images/close.png" alt="close"> Zatvori galeriju
    </div>
</div>

CSS

gallery {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #2a2d2c;
  z-index: 99999;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  display: none;
  .close-gallery {
    position: absolute;
    right: 5%;
    top: 5%;
    z-index: 1000;
    cursor: pointer;
    color: white;
    font-size: 1.2rem;
    img {
      vertical-align: middle;
      margin-right: 10px;
    }
  }
}

JQUERY(SLIDER是LightSlider)

$(document).ready(function () {
        $('#lightSlider').lightSlider({
            gallery: true,
            item: 1,
            loop: true,
            slideMargin: 0,
            thumbItem: 9
        });
    });

    $('.galerija-gumb').click(function () {
        $('.gallery').show();
        $('body').scrollTop(0);
    });

    $('.close-gallery').click(function () {
        $('.gallery').hide();
        var slider = $('#lightslider').lightSlider();
    });

因此,当我单击打开图库时,仅显示叠加,全屏元素

仅显示叠加层

当我调整画廊大小时显示?

在调整大小库后出现

当我从CSS中删除显示块时(因此始终显示全屏),库正常加载

在此处输入图像描述

演示: http//codepen.io/riogrande/pen/WxxjvJ


I have a jquery gallery which is placed inside of full screen absolutely positioned element and by default that element is hidden with display: none until you click a button and then that element is shown with jquery .show(). The problem is that when I click on a button, that fullscreen element is shown but everything inside that element (jquery gallery) is not visible. Only the fullscreen element is shown. When i remove the display none for the fullscreen element (so its shown on load) the gallery (or the content) is visible. Also in the case when its hidden by default and displays only the fullscreen element and not what is inside of it (gallery) when i resize the browser the gallery is shown?

DEMO: http://codepen.io/riogrande/pen/WxxjvJ

HTML

<div class="gallery">
    <div class="demo">
        <ul id="lightSlider">
            <li data-thumb="static/images/galerija/thumbs/15.jpg">
                <img src="static/images/galerija/15.jpg" alt="galerija"/>
            </li>
            <li data-thumb="static/images/galerija/thumbs/16.jpg">
                <img src="static/images/galerija/16.jpg" alt="galerija"/>
            </li>
            <li data-thumb="static/images/galerija/thumbs/17.jpg">
                <img src="static/images/galerija/17.jpg" alt="galerija"/>
            </li>
            <li data-thumb="static/images/galerija/thumbs/18.jpg">
                <img src="static/images/galerija/18.jpg" alt="galerija"/>
            </li>
        </ul>
    </div>
    <div class="close-gallery">
        <img src="static/images/close.png" alt="close"> Zatvori galeriju
    </div>
</div>

CSS

gallery {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #2a2d2c;
  z-index: 99999;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  display: none;
  .close-gallery {
    position: absolute;
    right: 5%;
    top: 5%;
    z-index: 1000;
    cursor: pointer;
    color: white;
    font-size: 1.2rem;
    img {
      vertical-align: middle;
      margin-right: 10px;
    }
  }
}

JQUERY (THE SLIDER IS LightSlider)

$(document).ready(function () {
        $('#lightSlider').lightSlider({
            gallery: true,
            item: 1,
            loop: true,
            slideMargin: 0,
            thumbItem: 9
        });
    });

    $('.galerija-gumb').click(function () {
        $('.gallery').show();
        $('body').scrollTop(0);
    });

    $('.close-gallery').click(function () {
        $('.gallery').hide();
        var slider = $('#lightslider').lightSlider();
    });

So when i click to open a gallery, only the overlay, fullscreen element is displayed

only overlay is displayed

When i resize the gallery is shown??

after resize gallery appears

When i remove the display block from CSS (so the fullscreen is shown all time) the gallery is loaded normally

enter image description here

DEMO: http://codepen.io/riogrande/pen/WxxjvJ


原文:https://stackoverflow.com/questions/37845101
更新时间:2022-05-29 15:05

最满意答案

分为两行

初始化空字典

>>> dict={}

使用列表理解更新字典

>>> for l1 in [{i:{'name':j,'price':None}} for i,j in enumerate(stp2)]:
    dict.update(l1)

最后的字典

>>> dict
{0: {'price': None, 'name': 'Anna'}, 1: {'price': None, 'name': 'William'}, 2: {'price': None, 'name': 'Mary'}, 3: {'price': None, 'name': 'Ben'}, 4: {'price': None, 'name': 'Richard'}, 5: {'price': None, 'name': 'Calvin'}, 6: {'price': None, 'name': 'Rock'}}

In two lines

initializing empty dictionary

>>> dict={}

Updating dictionary using list comprehension

>>> for l1 in [{i:{'name':j,'price':None}} for i,j in enumerate(stp2)]:
    dict.update(l1)

Final dictionary

>>> dict
{0: {'price': None, 'name': 'Anna'}, 1: {'price': None, 'name': 'William'}, 2: {'price': None, 'name': 'Mary'}, 3: {'price': None, 'name': 'Ben'}, 4: {'price': None, 'name': 'Richard'}, 5: {'price': None, 'name': 'Calvin'}, 6: {'price': None, 'name': 'Rock'}}

相关问答

更多
  • 我会做这样的事情 {k:str(v) for k,v in array} I'd do something like this {k:str(v) for k,v in array}
  • b = a不复制字典,它重新绑定b指向与a相同的对象(所以当您更改a ,您也可以观察对b的影响)。 b = copy.copy(a)使用b = copy.copy(a) ( copy模块)。 b = a doesn't copy the dictionary, it rebinds b to point at the same object as a (so when you change a, you can observe the effect on b as well). Use b = copy.c ...
  • 正如@NullUserException所说,一棵树(或类似它的东西)是一个不错的选择。 我发布的答案与您为此问题选择的内容完全不同。 您可以定义一个知道其名称的Person对象,并跟踪其父母是谁。 父母不是名字,而是另一个Person对象! (有点像链表)。 然后,您可以将人员集合保存为一个列表。 在解析文件时,您不断添加人员到列表中,同时使用正确的对象更新他们的子/父属性。 后来给了任何人,这只是打印属性来找到关系的问题 以下是一个可能的实现(在Python-2.6上)。 这种情况下的文本文件仅包含关系 ...
  • 分为两行 初始化空字典 >>> dict={} 使用列表理解更新字典 >>> for l1 in [{i:{'name':j,'price':None}} for i,j in enumerate(stp2)]: dict.update(l1) 最后的字典 >>> dict {0: {'price': None, 'name': 'Anna'}, 1: {'price': None, 'name': 'William'}, 2: {'price': None, 'name': 'Mary'}, ...
  • 怎么样: import copy tmp_keys = copy.copy(global_files) 根据global_files中的数据类型,它可能只传入引用。 How about: import copy tmp_keys = copy.copy(global_files) Depending on what kind of data is in global_files, it may only pass in a reference.
  • for attr, val in my_dict.items(): setattr(person, attr, val) 如果my_dict可能包含任何您不想复制到person的密钥,请创建您想要复制的密钥列表,并执行如下操作: key_list = ['name', 'surname', 'age', 'hair_color'] for attr in key_list: setattr(person, attr, my_dict[attr]) for attr, val in my_ ...
  • 对于numpy数组,您将使用名称arr和字典内的相同对象进行分配。 因此,当你修改它时,你会看到两者都出现变化,毕竟他们是同一个对象,而numpy数组是可变的 。 对于整数,当你执行dictionary["key"][1]+=1你在字典中创建一个新的整数,这是因为整数是不可变的 [1]。 这意味着两个整数( value和dictionary["key"][1] )是不同的对象,所以一个被修改,但另一个不是。 [1]它可能看起来像x = 2; x += 1 x = 2; x += 1在同一个对象上运行,毕竟+ ...
  • 这行不会创建两个单独的数组A和B ,它会生成一个数组并生成两个名称A和B ,引用该数组: A = B = np.zeros((len(X), len(X))) 例如: >>> A = B = np.zeros((3,3)) >>> A is B True >>> A[0,0] = 99 >>> A array([[ 99., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]]) >>> B array([[ 99., 0 ...
  • 在第一个.append()调用之后, data_out是[this_data_out] ,然后是第二个之后的[this_data_out, this_data_out] 。 将它附加到列表中并没有复制它的内容,它只是指向this_data_out中的内容 - 所以当你更改了那个字典时,你在列表中看到的内容也发生了变化。 data_out is [this_data_out] after the first .append() call, and then it's [this_data_out, this_ ...
  • 你肯定会在这里进行一些细节性的优化。 基于您在评论中提供的其他信息,这听起来像是最好的方法(没有升级内存,所以你可以处理更多的分配)可能是采取字典源代码并专门为一个新的类创建这个目的,如果它只改变一个值,它不会增加version字段。 You're definitely getting into some nitty-gritty performance optimization here. Based on the additional information you've given in the co ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。