简体   繁体   中英

How can I get simple Lightbox to show that scaling effect when hovering over an image

I have little experience with javascript and I am now building a little site with Django. Then I stumbled upon a site that mentioned SimpleLightbox.

So, here is what I got:

{% block content %}
    {% load static %}
    {% static "../" as baseURL %}
    <script src="http://code.jquery.com/jquery-3.5.1.min.js"></script>
        <link rel="stylesheet" href="{% static 'photo/css/simple-lightbox.min.css' %}">
    <script type="text/javascript" src="{% static 'photo/js/simple-lightbox.jquery.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'photo/js/simple-lightbox.js' %}"></script>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <h2 class="page-header-tuesday">Bilder Galerie</h2>
        <div class="row">
            <div class="col-sm-6 col-sm-offset-0 col-md-7 col-md-offset-0 text-mainframe">
                <br>
                <div class="gallery">
                    {% load photo_tags %}
                        {% if images %}
                            {% for image in images %}
                                {% with image|split:'.' as strs %}
                                {% with strs|length as str_arr_len %}
                                {% with str_arr_len|add:'-1' as ext_idx %}
                                {% if strs|get_by_index:ext_idx == 'jpg' %}
                                <a href="{{ MEDIA_URL}}ObjPDW2/bilder/{{ image }}">
                                    <img src="{{ MEDIA_URL }}ObjPDW2/bilder/{{ image }}" alt="{{ image }}">
                                    </a>
                                {% endif %}
                                {% endwith %}
                                {% endwith %}
                                {% endwith %}
                                {% if forloop.counter|divisibleby:4 %}
                                    <div class="clear"></div>
                                {% endif %}
                            {% endfor %}
                        {% else %}
                            <p>No image available.</p>
                        {% endif %}
                </div>

                <script type="text/javascript">
                    $(document).ready(function() {
                        var lightbox = $('.gallery a').simpleLightbox();
                    });
                </script>
            </div>
            <div class="col-md-4 col-sm-4 col-md-offset-1">
                    <br>
            </div>
        </div>
    </div>  
{% endblock %}

I can see the test image that I have in the folder. And when I follow the links to photo/css/simple-lightbox.min.css' and photo/js/simple-lightbox.jquery.min.js the source code is displayed correctly. However, I just see a normal image when I visit my site. When I hover over the image there is no scaling effect. When I click on the image, then the image is just displayed and nothing of these fancy lightbox things. So the site behaves as if there was no lightbox present and I would just have a code.

How could I find out what goes wrong?

Edit Now I have added two more js files. I do not really know how to handle web developer functions in Firefox, but at least I found a debugger that now says on page reload:"Paused on exception SyntaxError: Element.querySelectorAll: '\' is not a valid selector"

Solved by rearranging the order of js and css includes and putting it all at the end of the site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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