悬停时隐藏背景图层,将鼠标悬停在<p>元素上时隐藏

时间:2017-07-24 14:02:04

标签: javascript html css css3

我正在使用mixitup库来创建可排序的网格。我在各个网格项(.mix)之上有一个重叠的网格项(.image-over)。将鼠标悬停在网格项上时,背景中的div(带有背景图像)会变得模糊(.mix)并隐藏显示的文本(h1)。在重叠的div中显示一个新文本(p.descfirst)。当我将鼠标悬停在

内的新文本上时,文本会重新出现(h1)。关于如何避免这种情况的任何建议?

&#13;
&#13;
user_id   first_comment_date
&#13;
.mix,
.gap {
  display: inline-block;
  vertical-align: top;
}

.mix {
  background: #fff;
  margin-bottom: 1rem;
  position: relative;
  -webkit-filter: grayscale(0) blur(0);
  filter: grayscale(0) blur(0);
  transition: .4s ease-in-out;
  z-index: -1;
}

.image-over:hover .mix {
  position: relative;
  -webkit-filter: grayscale(100%) blur(2px);
  filter: grayscale(100%) blur(2px);
  transition: .1s ease-in-out;
}

.image-over {
  display: inline-block;
  position: relative;
  top: 0;
  z-index: 600;
  background: transparent;
}

.mix:before {
  content: '';
  display: inline-block;
  padding-top: 100%;
}

.mix h1 {
  font-weight: 1600;
  font-size: 500em;
  color: #fff;
  position: absolute;
  z-index: 2;
  top: 0;
  margin: 0 auto;
  padding: 5px;
  background: rgba(0, 0, 0, 0.3);
}

.mix:hover h1 {
  display: none;
}

.image-over:hover>p.descfirst {
  position: absolute;
  top: 40px;
  left: 40px;
  color: #ffffff;
  font-size: 16px;
  font-weight: bold;
  z-index: 1;
  transition: .2s ease-in-out;
  line-height: 25px;
  margin: 0;
}
&#13;
&#13;
&#13;

更新

由于运行代码段示例实际上并不起作用,因此可以使用一些屏幕截图来演示此问题。

Normal Grid styling with no mouse over On hover background image gets blurred, new <p> text appears When hovering over <p> element the h1 from underlying area reappears - I want to avoid this

1 个答案:

答案 0 :(得分:1)

我会使用mouseenter事件代替css一点点jquery。

https://api.jquery.com/mouseenter/

$( "#outer" ).mouseenter(function() {
    $( "#inner" ).doStuffHere();
});