简体   繁体   English

具有href标签的图片库

[英]Image gallery with href tag

I have a question 我有个问题

I have this code. 我有这个代码。 The code used to display a gallery, and it works perfect. 用于显示画廊的代码,它可以完美地工作。 I want now that when you click on any picture I show it in bigger resolution. 我现在想要的是,当您单击任何图片时,都以更大的分辨率显示它。 But when I put the href tag, the images not appear, if the link appears, but the images not appear. 但是,当我放置href标记时,如果出现链接,则图像不会出现,但是图像不会出现。

<div class="container">

    <div id="freewall" class="free-wall"></div>

    <script type="text/javascript">

        var temp = "<div class='brick' style='width:{width}px;'><img src='img/col1/{index}.jpg' width='100%'></div>";
        var w = 1, h = 1, html = '', limitItem = 24;
        for (var i = 0; i < limitItem; ++i) {
            w = 1 + 3 * Math.random() << 0;
            html += temp.replace(/\{width\}/g, w*150).replace("{index}", i + 1);
        }
        $("#freewall").html(html);

        var wall = new Freewall("#freewall");
        wall.reset({
            selector: '.brick',
            animate: true,
            cellW: 150,
            cellH: 'auto',
            onResize: function() {
                wall.fitWidth();
            }
        });

        var images = wall.container.find('.brick');
        images.find('img').load(function() {
            wall.fitWidth();
        });

    </script>

</div>

Images may not appear when I put the tag href 放置标签href时图像可能不会出现

var temp = "<div class='brick' style='width:{width}px;'><a href='img/col1/{index}.jpg'><img src='img/col1/{index}.jpg' width='100%'></a></div>";

Appears the link, but not the images. 显示链接,但不显示图像。

Any help I'm appreciate. 任何帮助,我都很感激。 Thanks 谢谢

I think more easily you can do is. 我认为您可以更轻松地做到。

.style1{
display:block;
width:100%;
}

add this class to your a tag 将此类添加到标签

<a class="style1" href='img/col1/{index}.jpg'>

Hope that helps 希望能有所帮助

Edited: 编辑:

The problem seems here. 问题似乎在这里。

.replace("{index}", i + 1);

use this. 用这个。

.replace("/{index}/g", i + 1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM