简体   繁体   English

具有锚标记的JQuery超大型插件问题

[英]JQuery Supersized Plugin Problem with Anchor Tag

I'm currently utilizing the Supersized plugin for JQuery and I'm running into a problem with the anchor tag for the banners not being clickable. 我目前正在将Supersized插件用于JQuery,并且遇到横幅无法点击的锚标记的问题。

I have Supersized being appended to a div tag instead of the body tag. 我将Supersized附加到div标签而不是body标签上。

I set "#supersized" and "#supersized li" to be positioned absolute to fit properly within the containing div. 我将“ #supersized”和“ #supersized li”设置为绝对位置,以正确地包含在包含div中。 But that dang anchor link will not overlay over the image and be clickable. 但是,当当锚链接不会覆盖在图像上,而是可以单击的。 I've tried increasing the z-index to 90. 我尝试将z-index增大到90。

I've tried everything I know but I still can't get it to work. 我已经尝试了所有我知道的东西,但是仍然无法正常工作。 I placed a border around the anchor tag and it pushes the image down but it's not clickable. 我在锚标记周围放置了一个边框,它将图像向下推,但是无法点击。

CSS 的CSS

img { border:none; }

#supersized-loader { position:absolute; top:50%; left:50%; z-index:0; width:60px; height:60px; margin:-30px 0 0 -30px; text-indent:-999em; background:url(../img/progress.gif) no-repeat center center;}

  #supersized {  display:block; position:absolute; left:0; top:0; overflow:hidden; z-index:-999; height:100%; width:100%; }
  #supersized img { width:auto; height:auto; position:relative; display:none; outline:none; border:none; }
  #supersized.speed img { -ms-interpolation-mode:nearest-neighbor; image-rendering: -moz-crisp-edges; }   /*Speed*/
  #supersized.quality img { -ms-interpolation-mode:bicubic; image-rendering: optimizeQuality; }         /*Quality*/

  #supersized li { display:block; list-style:none; z-index:-30; position:absolute; overflow:hidden; top:0; left:0; width:100%; height:100%; background:#111; }
  #supersized a { width:100%; height:100%; display:block; }
     #supersized li.prevslide { z-index:-20; }
     #supersized li.activeslide { z-index:-10; }
     #supersized li.image-loading { background:#111 url(../img/progress.gif) no-repeat center center; width:100%; height:100%; }
        #supersized li.image-loading img{ visibility:hidden; }
     #supersized li.prevslide img, #supersized li.activeslide img{ display:inline; }

JavaScript 的JavaScript

<script type="text/javascript">

     jQuery(function($){

        $.supersized({

           // Functionality
           slide_interval           :   3000,      // Length between transitions
           transition                 :   1,          // 0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
           transition_speed      :   700,      // Speed of transition

           // Options
           fit_always                 :    0,
           fit_portrait                 :    0,
           horizontal_center     :    1,
           slide_links                :    'blank',   // Individual links for each slide (Options: false, 'number', 'name', 'blank')
           vertical_center         :    1,

           slides  :     [ 
                       {image : 'images/homepageBanners/banner1.jpg', title : 'Banner 1', url : "http://www.yahoo.com"},
                       {image : 'images/homepageBanners/banner2.jpg', title : 'Banner 2', url : "http://www.yahoo.com"},
                       {image : 'images/homepageBanners/banner3.jpg', title : 'Banner 3', url : "http://www.yahoo.com"},
                       {image : 'images/homepageBanners/banner4.jpg', title : 'Banner 4', url : "http://www.yahoo.com"}
                    ]
        });
      });

</script>

HTML is a simple div tag contained in page wrapper. HTML是页面包装中包含的简单div标签。 I changed the output of the Supersized slider so that it appends to the div tag instead of the body tag. 我更改了Supersized滑块的输出,以便将其附加到div标签而不是body标签。

<div id="HomePageBanners"></div>

The javascript in supersized has been altered to append to the above div tag: 加大号中的javascript已更改为追加到上述div标签:

$(document).ready(function() {
     $('#HomePageBanners').append('<div id="supersized-loader"></div><ul id="supersized"></ul>');
});

Ok there are 2 things wrong with your code, first you have an insane negative z-index on #supersized automatically pulling everything in it down to the bottom too... 好的,您的代码有2件事情出错,首先您在#supersized上有一个疯狂的负z索引,它#supersized自动将其中的所有内容#supersized底部...

What you want to do instead is have #supersized have a modest z-index, then everything that needs to go above it gets one a little higher... Or the link will be blocked by standard elements like body... 相反,您要执行的操作是#supersized具有适度的z-index,然后需要超出该值的所有内容都会稍高一点...否则该链接将被body等标准元素阻止...

Secondly visibility:hidden makes sure the link is not visible and will block the href too... afaik. 其次, visibility:hidden确保链接不可见,并且也会阻止href ... afaik。

Heres your code, css and js, tweaked, with a working link in the example area left bottom http://jsfiddle.net/sg3s/daeL3/ 使用以下示例区域中的工作链接对以下代码,css和js进行了调整:左下角http://jsfiddle.net/sg3s/daeL3/

As a bonus heres how I debugged it: if you use the element inspector in either firefox/firebug or in chrome the very first element you can directly click on will be the top element. 作为奖励,这里介绍了我如何调试它:如果在firefox / firebug或chrome中使用元素检查器,则可以直接单击的第一个元素将是顶部元素。 So using that I was able to determine that body was blocking the link. 因此,使用该链接,我可以确定主体正在阻止链接。 Secondly since I can't directly see the link I added some text in it... With little effect so I selected the link and worked my way up through it's styles and all of the parents eliminating things that can block the display of the link, narrowing it down to visibility: hidden 其次,由于我无法直接看到该链接,因此在其中添加了一些文本...影响不大,因此我选择了该链接,并逐步解决了其样式,所有父母消除了会阻塞链接显示的内容,将其范围缩小到visibility: hidden

Additionally the little js snipped on the end is just an alternative way to make sure that what you're clicking is what you think it is... 另外,在末端剪下的小js只是确保您单击的内容是您认为的真实内容的另一种方法...

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

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