默认情况下隐藏叠加层时,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中删除显示块时(因此始终显示全屏),库正常加载
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
When i resize the gallery is shown??
When i remove the display block from CSS (so the fullscreen is shown all time) the gallery is loaded normally
原文:https://stackoverflow.com/questions/37845101
最满意答案
分为两行
初始化空字典
>>> 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 ...
-
循环字典值(Looping dictionary values)[2021-08-27]
正如@NullUserException所说,一棵树(或类似它的东西)是一个不错的选择。 我发布的答案与您为此问题选择的内容完全不同。 您可以定义一个知道其名称的Person对象,并跟踪其父母是谁。 父母不是名字,而是另一个Person对象! (有点像链表)。 然后,您可以将人员集合保存为一个列表。 在解析文件时,您不断添加人员到列表中,同时使用正确的对象更新他们的子/父属性。 后来给了任何人,这只是打印属性来找到关系的问题 以下是一个可能的实现(在Python-2.6上)。 这种情况下的文本文件仅包含关系 ... -
在循环字典中分配值(Assigning values in looped dictionary)[2022-08-26]
分为两行 初始化空字典 >>> 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在同一个对象上运行,毕竟+ ...
-
循环vs批量算术(Looped vs Bulk arithmetic)[2023-06-03]
这行不会创建两个单独的数组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 ...