lightgallery在全屏弹出窗口中显示不正确。

huangapple go评论64阅读模式
英文:

lightgallery not showing correctly in fullscreen popup

问题

我创建了一个类似这样的图库。

然后初始化 lightGallery,它会显示如下。

有任何想法为什么?

编辑:

添加了代码片段,你可以看到缩略图栏在左侧以列的形式显示,而不是在这个工作示例中的底部 https://codepen.io/AquaMay/pen/PoPzNjB

看起来你的帖子主要是代码;请添加更多细节。
看起来你的帖子主要是代码;请添加更多细节。
看起来你的帖子主要是代码;请添加更多细节。

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>JS Bin</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@2.0.0-beta.4/css/lightgallery.css">
    <style>
      #lightGallery img {
        height: 75px;
      }
      #lightGallery a {
        text-decoration: none;
        color: black;
      }
    </style>
  </head>
  <body>
    <div id="lightGallery">
      <a href="https://picsum.photos/1080/720?random=1">
        <img src="https://picsum.photos/1080/720?random=1" />
      </a>

      <a href="https://picsum.photos/1080/720?random=2">
        <img src="https://picsum.photos/1080/720?random=2" />
      </a>

      <!-- 更多图片 -->

    </div>
    <script type="module">
      import lightGallery from "https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/optimized/lightgallery.js";
      import lgFullscreen from "https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/unoptimized/plugins/fullscreen/lg-fullscreen.es5.js";
      import lgPager from "https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/unoptimized/plugins/pager/lg-pager.es5.js";
      import lgThumbnail from "https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/unoptimized/plugins/thumbnail/lg-thumbnail.es5.js";

      window.addEventListener("DOMContentLoaded", (event) => {
        lightGallery(document.getElementById("lightGallery"), {
          speed: 500,
          allowMediaOverlap: true,
          enableSwipe: true,
          plugins: [lgPager, lgFullscreen, lgThumbnail],
        });
      });
    </script>
  </body>
</html>

<details>
<summary>英文:</summary>

I create a gallery like this.

[![enter image description here][1]][1]

Then initialize the lightGallery and this is how it shows up.

[![enter image description here][2]][2]


Any idea why?


# Edit:
Added Snippet, as you can see the thumbnails bar is on the left as a column instead of on the bottom like in this working example https://codepen.io/AquaMay/pen/PoPzNjB

It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
&lt;!-- begin snippet: js hide: false console: true babel: false --&gt;

&lt;!-- language: lang-html --&gt;

    &lt;!DOCTYPE html&gt;
    &lt;html&gt;
      &lt;head&gt;
        &lt;meta charset=&quot;utf-8&quot; /&gt;
        &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&quot; /&gt;
        &lt;title&gt;JS Bin&lt;/title&gt;
        &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/lightgallery@2.0.0-beta.4/css/lightgallery.css&quot;&gt;
        &lt;style&gt;
          #lightGallery img {
            height: 75px;
          }
          #lightGallery a {
            text-decoration: none;
            color: black;
          }
        &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
        &lt;div id=&quot;lightGallery&quot;&gt;
          &lt;a href=&quot;https://picsum.photos/1080/720?random=1&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=1&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=2&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=2&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=3&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=3&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=4&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=4&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=5&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=5&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=6&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=6&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=7&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=7&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=8&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=8&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=9&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=9&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=10&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=10&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=11&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=11&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=12&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=12&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=13&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=13&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=14&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=14&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=15&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=15&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=16&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=16&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=17&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=17&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=18&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=18&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=19&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=19&quot; /&gt;
          &lt;/a&gt;

          &lt;a href=&quot;https://picsum.photos/1080/720?random=20&quot;&gt;
            &lt;img src=&quot;https://picsum.photos/1080/720?random=20&quot; /&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;script type=&quot;module&quot;&gt;
          import lightGallery from &quot;https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/optimized/lightgallery.js&quot;;
          import lgFullscreen from &quot;https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/unoptimized/plugins/fullscreen/lg-fullscreen.es5.js&quot;;
          import lgPager from &quot;https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/unoptimized/plugins/pager/lg-pager.es5.js&quot;;
          import lgThumbnail from &quot;https://cdn.skypack.dev/pin/lightgallery@v2.0.0-beta.4-flTmGp4UDZ7xjie9ui6y/mode=imports/unoptimized/plugins/thumbnail/lg-thumbnail.es5.js&quot;;

          window.addEventListener(&quot;DOMContentLoaded&quot;, (event) =&gt; {
            lightGallery(document.getElementById(&quot;lightGallery&quot;), {
              speed: 500,
              allowMediaOverlap: true,
              enableSwipe: true,
              plugins: [lgPager, lgFullscreen, lgThumbnail],
            });
          });
        &lt;/script&gt;
      &lt;/body&gt;
    &lt;/html&gt;


&lt;!-- end snippet --&gt;

  [1]: https://i.stack.imgur.com/nyNnE.png
  [2]: http://i.imgur.com/zXY20O9h.gif

</details>


# 答案1
**得分**: 0

问题在于插件也有CSS文件,而我漏掉了这些文件。

https://cdn.jsdelivr.net/npm/lightgallery@2.0.0-beta.3/css/lg-thumbnail.css
https://cdn.jsdelivr.net/npm/lightgallery@2.0.0-beta.3/css/lg-pager.css


<details>
<summary>英文:</summary>

The problem was that plugins have CSS files too, and I was missing those files.

https://cdn.jsdelivr.net/npm/lightgallery@2.0.0-beta.3/css/lg-thumbnail.css
https://cdn.jsdelivr.net/npm/lightgallery@2.0.0-beta.3/css/lg-pager.css


</details>



huangapple
  • 本文由 发表于 2023年7月13日 22:05:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680286.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定