css - 链接有时在页面加载时可点击,有时不可点击

标签 css debugging hyperlink

我正在构建一个网站,该网站使用 Jquery 和一些花哨的 CSS 在首页上驱动图片库。

图库基于本教程: http://tympanus.net/codrops/2012/02/06/3d-gallery-with-css3-and-jquery/

这是我遇到问题的网页:http://www.apexdesignstudios.com/index.html

我根据自己对网站的需要修改了 css 和 html,这是我的代码:

<div class="content-bg">
<div class="container_16" id="content">
    <div id="dg-container" class="dg-container">
    <div class="dg-wrapper">
    <a href="#image-1"><img src="thumbs/1.jpg" alt="image01"></a>
    <a href="#image-2"><img src="thumbs/2.jpg" alt="image02"></a>
    <a href="#image-3"><img src="thumbs/3.jpg" alt="image03"></a>
    <a href="#image-4"><img src="thumbs/4.jpg" alt="image04"></a>
    <a href="#image-5"><img src="thumbs/5.jpg" alt="image05"></a>
    <a href="#image-6"><img src="thumbs/6.jpg" alt="image06"></a>
    <a href="#image-7"><img src="thumbs/7.jpg" alt="image07"></a>
    <a href="#image-8"><img src="thumbs/8.jpg" alt="image08"></a>
    <a href="#image-9"><img src="thumbs/9.jpg" alt="image09"></a>
    <a href="#image-10"><img src="thumbs/10.jpg" alt="image10"></a>
    <a href="#image-11"><img src="thumbs/11.jpg" alt="image11"></a>
    <a href="#image-12"><img src="thumbs/12.jpg" alt="image12"></a>
    <a href="#image-13"><img src="thumbs/13.jpg" alt="image13"></a>
    <a href="#image-14"><img src="thumbs/14.jpg" alt="image14"></a>
    <a href="#image-15"><img src="thumbs/15.jpg" alt="image15"></a>
    <a href="#image-16"><img src="thumbs/16.jpg" alt="image16"></a>
    </div>
<nav> 
    <span class="dg-prev"><</span>
    <span class="dg-next">></span>
</nav>
    </div>                   
</div>

然后是单击缩略图时的叠加层:

<div class="gallery-overlay" id="image-1">
            <img src="images/1.jpg"/>
                <div>
                    <h3><img src="images/apex.png"/></h3>
                    <p>Aureus Evolution Proof<br>by Gabor Mechtler</p>
                </div>
                <a href="#page" class="gallery-close">CLOSE</a>
        </div>
        <div class="gallery-overlay" id="image-2">
            <img src="images/2.jpg"/>
                <div>
                    <h3><img src="images/apex.png"/></h3>
                    <p>BFX Proof<br>by Gabor Mechtler</p>
                </div>
                <a href="#page" class="gallery-close">CLOSE</a>
        </div>

我省略了其余的覆盖代码,然后对 16 张图像重复这些代码。

CSS:

.dg-container
{
width: 100%;
height: 280px;
position: relative;
padding-top: 10px;
}
.dg-wrapper
{
width: 300px;
height: inherit;
margin-left: auto;
margin-right: auto;
position: relative;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-perspective: 1000px;
-moz-perspective: 1000px;
-o-perspective: 1000px;
-ms-perspective: 1000px;
perspective: 1000px;
}

.dg-wrapper a
{
width: inherit;
height: inherit;
display: block;
position: absolute;
left: 0;
top: 0;
}

.dg-wrapper a.dg-transition
{
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.dg-wrapper a img
{
display: block;
margin-left: auto;
margin-right: auto;
padding: 5px 0px 2px 0px;
}
.dg-wrapper a div
{
font-style: italic;
text-align: center;
margin-top: 2%;
text-shadow: 1px 1px 1px rgba(255,255,255,0.5);
color: #333;
font-size: 16px;
width: 100%;
display: none;
position: absolute;
}

.dg-wrapper a.dg-center div
{
display: block;
}
.dg-container nav
{
width: 80px;
height: 50px;
position: relative;


margin-left: auto;
margin-right: auto;

}
.dg-container nav span
{
text-indent: -9000px;
float: left;
cursor:pointer;
width: 35px;
height: 40px;
opacity: 0.8;
background: transparent url(../images/arrows.png) no-repeat top left;
padding-bottom: 10px;
}
.dg-container nav span:hover
{
opacity: 1;
}
.dg-container nav span.dg-next
{
background-position: top right;
margin-left: 10px;
}


.gallery-overlay
{
width: 0px;
height: 0px;
position: fixed;
overflow: hidden;
left: 0px;
top: 0px;
padding: 0px;
z-index: 99;
text-align: center;
background: rgb(0,0,0);
/* background: -moz-radial-gradient(center, ellipse cover, rgba(255,255,255,0.56) 0%, rgba(241,210,194,1) 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(255,255,255,0.56)), color-stop(100%,rgba(241,210,194,1)));
background: -webkit-radial-gradient(center, ellipse cover, rgba(255,255,255,0.56) 0%,rgba(241,210,194,1) 100%);
background: -o-radial-gradient(center, ellipse cover, rgba(255,255,255,0.56) 0%,rgba(241,210,194,1) 100%);
background: -ms-radial-gradient(center, ellipse cover, rgba(255,255,255,0.56) 0%,rgba(241,210,194,1) 100%);
background: radial-gradient(center, ellipse cover, rgba(255,255,255,0.56) 0%,rgba(241,210,194,1) 100%); */
}

.gallery-overlay > div
{
position: relative;
color: rgba(27,54,81,0.8);
width: 550px;
height: 80px;
margin: 40px auto 0px auto;
text-shadow: 0px 1px 1px rgba(255,255,255,0.6);
}

.gallery-overlay div h3,
.gallery-overlay div p
{
padding: 0px 20px;
width: 200px;
height: 60px;
}
.gallery-overlay div h3
{
float: left;
border-right: 1px solid #0090ff;
}
.gallery-overlay div h3 span,
.gallery-overlay div p
{
color: #FFFFFF;
font-family: Constantia, Palatino, "Palatino Linotype", "Palatino LT STD", Georgia, serif;
}
.gallery-overlay div h3 span
{
display: block;
line-height: 6px;
}
.gallery-overlay div p
{
font-size: 1.25em;
text-align: right;
float: left;

}
.gallery-overlay a.gallery-close
{
z-index: 1001;
color: #F00;
position: absolute;
top: 50px;
left: 50%;
font-size: 1.5em;
line-height: 25px;
text-align: center;
width: 70px;
height: 25px;
overflow: hidden;
margin-left: -25px;
opacity: 0; /* filter: alpha(opacity=0); /* internet explorer */
/* -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; /*IE8*/
/* -webkit-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 1px 2px rgba(0,0,0,0.3);
box-shadow: 0px 1px 2px rgba(0,0,0,0.3); */
}
.gallery-overlay img
{
/* height: 100%; For Opera max-height does not seem to work */
max-height: 100%;
position: relative;
opacity: 0;
filter: alpha(opacity=0); /* internet explorer */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; /*IE8*/
-webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
-moz-box-shadow: 1px 1px 4px rgba(0,0,0,0.3);
box-shadow: 0px 2px 7px rgba(0,0,0,0.2);
-webkit-transition: opacity 0.5s linear;
-moz-transition: opacity 0.5s linear;
-o-transition: opacity 0.5s linear;
-ms-transition: opacity 0.5s linear;
transition: opacity 0.5s linear;
}

.gallery-overlay:target 
{
width: auto;
height: auto;
bottom: 0px;
right: 0px;
padding: 80px 100px 120px 100px;
}
.gallery-overlay:target img,
.gallery-overlay:target a.gallery-close
{
opacity: 1;
filter: alpha(opacity=99); /* internet explorer */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=99)"; /*IE8*/
}
/* 
100% Height for Opera as the max-height seems to be ignored, not optimal for large screens 
http://bricss.net/post/11230266445/css-hack-to-target-opera 
*/
x:-o-prefocus, .gallery-overlay img 
{
height: 100%;
}

因此,如果您加载该页面,您可能会注意到前面中间的缩略图是可点击的,而其两侧的 2 个是不可点击的。随机刷新页面几次后,侧面缩略图确实可以点击。我只是无法弄清楚我哪里出错了...我认为它在 CSS 文件中的某个地方(CSS 文件是草稿/WIP),但我仍然不确定。

提前感谢您的输入! 皮特

最佳答案

您的问题是因为放置了不同的元素,快速解决此问题的方法是将 98 的 z-index 属性应用于类 .dg-containerstyles.css 中,数字可以是小于 99 的任何值,因为您已经在 .gallery-overlay 类上设置了 z-index > 到 99

CSS

.dg-container {
    width: 100%;
    height: 280px;
    position: relative;
    padding-top: 10px;
    z-index: 98;
}

关于css - 链接有时在页面加载时可点击,有时不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15752567/

相关文章:

c - 我的堆栈中 argv 和 argc 之间的空间是多少?

node.js - 调试proctor(带/不带webstorm)

Twitter Widget 仅显示链接

ios - swift : How to open a link when tap on text in label?

javascript - 在 HTML 标题选项卡中传递 AJAX 响应

css - 如何仅使用 CSS 创建箭头?

像 netflix 封面图片一样的 CSS 转换

javascript - 滚动行为结束 : smooth scroll

android - 编译后将 Android 应用程序设置为可调试

jquery - 光标在被抑制的链接上