简体   繁体   English

使<a>点击可点击</a> <div>

[英]Make <a> clickable behind a <div>

I have a site where as the header there is a linked image. 我有一个网站,其中的标题是链接的图像。 In front of it there is an information box about it. 它前面有一个信息框。 The problem is that you can't click the link in the horizontal area where the information div is wrapped. 问题是您无法单击包装了div信息的水平区域中的链接。 The wrapper is necessary to get the information box centered. 必须使用包装器才能使信息框居中。

The image below shows the site. 下图显示了该站点。 I have marked the non clickable area red. 我已将不可点击区域标记为红色。 My goal is to have click access everywhere around the text boxes. 我的目标是在文本框周围的任何地方都具有单击访问权限。

我想要的屏幕截图

I need to fix this without deleting the wrapper and positioning the info boxes with "position absolute" because there is jQuery doing some stuff in the background. 我需要解决此问题,而不必删除包装器并使用“ position absolute”来定位信息框,因为jQuery在后台做了一些工作。

here the html wrap structure: 这里是html wrap结构:

        <a href="#" class="showTag"></a>
        <div id="title">
            <div id="innerTitle">
                <div id="mainTitle"></div>
                <div id="downloadWrapper"></div>
            </div>
        </div>

"title" and "innerTitle" are causing the trouble. “标题”和“ innerTitle”正在引起麻烦。 They are the wrappers which I need to display "mainTitle" and "downloadWrapper" centered. 它们是我需要以居中显示“ mainTitle”和“ downloadWrapper”的包装器。

here is the link to the site if you wish to take a look at the code: http://n.ethz.ch/student/lukal/paint.net/ 如果您想看一下代码,这里是网站的链接: http : //n.ethz.ch/student/lukal/paint.net/

Thanks in advance :D 提前致谢

not sure what element you want to click, because both boxes in the image are clickable (at least in FF), but the answer for ANY element is pointer-events:none . 不确定要单击哪个元素,因为图像中的两个框都是可单击的(至少在FF中),但是ANY元素的答案是pointer-events:none。 Simply add this to any element you need (for example if you want to click the sliding divs) and voila! 只需将其添加到所需的任何元素中(例如,如果您想单击滑动div),瞧! Basically, you can access any element despite its z-index 基本上,您可以访问任何元素,尽管其z-index

You can read more about Pointer-Events 您可以阅读有关指针事件的更多信息

获取链接的目标,然后将单击操作应用于实际被单击的<div>本身。

Ok Thank you Fabio. 好,谢谢法比奥。 The Answer is, I needed to apply pointer-events:none to the wrapper and then apply pointer-events:all to those elements inside, which I still want to access, like the info-box. 答案是,我需要将pointer-events:none应用于包装器,然后将pointer-events:all应用于内部那些我仍要访问的元素,例如信息框。 That's how you can basically mask out the empty areas occupied by the wrapper. 这样基本上可以掩盖包装程序所占用的空白区域。

<style>
#downloadWrapper:hover
{
z-index:99 !important;
}
</style>

<a href="#" class="showTag"></a>
<div id="title">
<div id="innerTitle">
<div id="mainTitle"></div>
<div id="downloadWrapper"></div>
</div>
</div>

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

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