简体   繁体   English

我的锚标签不起作用。

[英]My anchor tags are not working.

The issue is as it says in the title, clicking on an image wrapped with an anchor tag doesnt work.问题正如标题中所说,单击带有锚标记的图像不起作用。

Here is an example of on grid list item:以下是网格列表项的示例:

<li class="grid-list-item">
            <h3 class="grid-trail-name">Marshall Canyon</h3><span class="grid-loc">Mt Baldy, California</span>
            <div class="grid-overlay">
                <span class="grid-close">close</span>
                <div class="grid-trail">
                    <div class="open">
                        <div class="info-flex info">
                            <div class="info-sum info-flex-child">
                                <h3 class="info-sum-header">Marshall Canyon...</h3>
                                <p class="info-sum-text">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque imperdiet massa sed augue posuere aliquet. Sed ac eros convallis, porttitor tellus in, blandit lacus. Suspendisse mollis quis turpis ac tempor. Pellentesque imperdiet massa sed augue posuere aliquet. Sed ac eros convallis, porttitor tellus in, blandit lacus. Suspendisse mollis quis turpis ac tempor. </p>
                            </div>
                            <div class="info-map info-flex-child">
                                <a href="http://www.ramblr.com/web/mymap/trip/81548/154499" target="_blank" ><img src="http://www.ramblr.com/media/photo/map/20150714/0000154499_big_english.jpg?q=1461036407851" data-item="map_img" data-src="http://www.ramblr.com/media/photo/map/20150720/0000158962_big_english.jpg"  class="map"> </a>
                            </div>
                            <div class="info-graph info-flex-child">
                                <a href="http://www.ramblr.com/web/mymap/trip/81548/154499" target="_blank" ><img src="http://www.ramblr.com/media/photo/chart/20150714/0000154499_1_english.jpg?q=1461036467654" data-item="chart_img" data-src="http://www.ramblr.com/media/photo/chart/20150720/0000158962_1_english.jpg" class="graph"></a>
                            </div>
                            <div class="info-pic-section info-flex-child">
                                <img src="images/marshall.jpg" alt="" class="info-pic">
                            </div>
                        </div><!-- GRID INFO -->
                    </div><!-- OPEN -->
                </div><!-- GRID TRAIL -->
            </div><!-- GRID OVERLAY -->
        </li><!-- GRID ITEM -->

grid-overlay remains hidden until the user clicks on the grid item. grid-overlay 保持隐藏,直到用户点击网格项。 Once clicked the info section is displayed.单击后,将显示信息部分。 Within the info section there is a map and a graph that should open a new anchor tag once they are clicked.在信息部分有一个地图和一个图表,一旦点击它们应该打开一个新的锚标签。

My guess is that the script I used to achieve this effect is what is causing the issue boxgrid.js .我的猜测是我用来实现这种效果的脚本是导致 boxgrid.js 问题的原因。 Find the github repo here and the site is up on surge here .此处找到 github 存储库,该站点在此处激增。

The problem is with where the <div class="grid-overlay"> content resides in the DOM.问题在于<div class="grid-overlay">内容在 DOM 中的位置。 Currently, there are 12 of them, 1 inside each list item.目前,有 12 个,每个列表项中有 1 个。 You'll need these overlays to live outside of the list items.您需要这些叠加层位于列表项之外。

Check out the following gif.看看下面的gif。

在此处输入图片说明

I click on one of the starting list items and the overlay comes up.我单击起始列表项之一,叠加层出现。 As usual, clicking on the map anchor doesn't work.像往常一样,点击地图锚点不起作用。 Then I drag the <div class="grid-overlay"> DOM outside of its list item and drop it right before </body> .然后我将<div class="grid-overlay"> DOM 拖到其列表项之外并将其放在</body>之前。 The styles are a little messed up now (needs a background color applied), but the point is that the map anchor link now works.样式现在有点乱(需要应用背景颜色),但关键是地图锚链接现在可以工作了。

One solution to this would be to move all the <div class="grid-overlay"> elements just before </body> and add a data attribute on each one, associating it with the hiking destination.对此的一种解决方案是将所有<div class="grid-overlay">元素移动到</body>之前,并在每个元素上添加一个数据属性,将其与远足目的地相关联。 For example:例如:

<div class="grid-overlay" data-belongs-to="Potato Mountain">

Then, you could associate this destination with the clicked list item:然后,您可以将此目的地与单击的列表项相关联:

<li class="grid-list-item" data-location="Potato Mountain">

At this point, you'd have to mess with the original script a little.在这一点上,您必须稍微弄乱原始脚本 You'd want to change:你想改变:

$overlay = $item.children( 'div.grid-overlay' )

because the <div class="grid-overlay"> elements would no longer reside as children inside of each $item .因为<div class="grid-overlay">元素将不再作为每个$item子元素驻留。

Good luck!祝你好运!

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

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