:: before伪元素时,锚元素不起作用 [英] anchor element not working when ::before pseudo element

查看:85
本文介绍了:: before伪元素时,锚元素不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在父级::before上应用了一些样式,并且其中的anchor元素不再起作用.

I have applied some styles on the parent ::before and the anchor element inside doesn't work anymore.

似乎有些东西覆盖了anchor元素的默认行为,但我不知道是什么.

It seems that something is overriding the default behavior of the anchor element but I can not figure out what.

我该如何解决?

.ugallery_item::before {
content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  transition:all 0.8s;
  opacity:0;
  background:url("http://placehold.it/14x14") #eabe24 no-repeat center center;
}
.ugallery_item:hover::before {
  opacity:0.8;
}

<div class="ugallery_item ugallery_item_image  shuffle-item filtered" style="position: absolute; width: 140px; top: 0px; left: 0px; opacity: 1;" rel="706" data-groups="[&quot;label_0&quot;]">
    <a class="ugallery_link ugallery_lightbox_link" href="http://placehold.it/300x400" title="">
      <img src="http://placehold.it/150x150" alt="" class="ugallery-image" style=" margin-left:0px;  margin-top:0px;width:140px; height:140px">
        <div class="ugallery_lb_text" rel="706"></div>

    </a>
</div>

推荐答案

您已经将伪元素完全定位在链接上了.因此,鼠标自然无法点击它.

You've absolutely positioned the pseudo-element over the link..so naturally the mouse can't click on it.

您将伪元素移至实际链接.

You move the pseudo-element to the actual link instead.

.ugallery_item {
  position: absolute;
  width: 140px;
  top: 0px;
  left: 0px;
  opacity: 1;
}
.ugallery_lightbox_link {
  display: block;
  position: relative;
}
.ugallery_lightbox_link:before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  transition: all 0.8s;
  opacity: 0;
  background: url("http://placehold.it/14x14") #eabe24 no-repeat center center;
}
.ugallery_lightbox_link:before {
  opacity: 0.8;
}

<div class="ugallery_item ugallery_item_image  shuffle-item filtered" rel="706" data-groups="">
  <a class="ugallery_link ugallery_lightbox_link" href="http://placehold.it/300x400" title="">
    <img src="http://placehold.it/150x150" alt="" class="ugallery-image" style=" margin-left:0px;  margin-top:0px;width:140px; height:140px" />

    <div class="ugallery_lb_text" rel="706"></div>

  </a>

</div>

这篇关于:: before伪元素时,锚元素不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆