我正在为我的应用程序使用网格库。这个画廊正是我想要的。它完全符合我的需要,我不想改变它。但是,我需要对它作两项修改,如果没有这些改动,对我来说是不完整的。但我不知道该怎么做。所需的修改如下:
现在,这里要注意的是,问题1与问题2有关,因为不能单击用户名,因为在整个图像打开后,图像在屏幕上的任何位置(包括图像)第一次单击都会关闭。
代码笔片段:[https://codepen.io/zoomkraft/pen/KKKNVXN](https://codepen.io/zoomkraft/pen/KKKNVXN)
[1]: https://www.codepen.io/zoomkraft/pen/KKKNVXN
发布于 2019-10-19 05:16:46
。
gallery.querySelectorAll(".gallery-item").forEach(function(item) {
item.addEventListener("click", function(event) {
// If image is in full mode and the click event was fired by an img or a element, do not toggle the full class
if (item.classList.contains("full") && ['IMG', 'A'].includes(event.target.tagName)) {
return;
}
item.classList.toggle("full");
});
});
这是您编辑的代码:https://codepen.io/giuseppedeponte/pen/gOOLPya?editors=0010
要让您的链接动态地从图像中获取其宽度,您可能应该在它们周围放置一个包装器。
https://stackoverflow.com/questions/58460315
复制相似问题