CSS z-index属性没有';行不通

CSS z-index属性没有';行不通,css,z-index,css-filters,Css,Z Index,Css Filters,我试图给一个带有“filter”属性的div(背景图片)一个悬停效果。但它对另一个本该结束的部门(我的文本)产生了影响。 我应用了z-index属性(没有忘记div的位置),但它不起作用。你会看到,我的文字也模糊了,不应该这样。你能告诉我我的密码有什么问题吗 下面是显示我的问题的代码笔: HTML 非常感谢 当您在元素上添加效果时,在大多数情况下,它们的子元素也会受到影响,因此在这种情况下,您可以对背景图像使用伪元素 更改CSS规则 .left_part { height: 40vh;

我试图给一个带有“filter”属性的div(背景图片)一个悬停效果。但它对另一个本该结束的部门(我的文本)产生了影响。 我应用了z-index属性(没有忘记div的位置),但它不起作用。你会看到,我的文字也模糊了,不应该这样。你能告诉我我的密码有什么问题吗

下面是显示我的问题的代码笔:

HTML


非常感谢

当您在元素上添加效果时,在大多数情况下,它们的子元素也会受到影响,因此在这种情况下,您可以对
背景图像使用伪元素

更改CSS规则

.left_part {
  height: 40vh;
  position: relative;
  background-color: #000;
  box-shadow: 0 50px 60px 0 rgba(0,0,0,.35);
  border-radius: 10px;
}

.left_part::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background-image: url(http://lorempixel.com/500/200/nature/1/);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-color: #000;
  border-radius: 10px;
}

.left_part:hover::before {
  -webkit-filter: blur(5px);
  filter: blur(5px);
}
请看这里:


我将文本部分元素从待模糊背景div中取出,现在两者都有相同的父元素。接下来,我以不同的方式解决了定心问题,通常的方法(绝对位置、顶部和左侧50%,
transform:translate(-50%,-50%)
。然后,我将
指针事件:无;
应用到文本层,以便它下面的悬停可以显示word。我还添加了一个影响文本的不同悬停规则-请参阅我的代码笔。HTH

模糊属性模糊所有元素和子元素,您无法以这种方式制作所需内容
.container {
  margin-right: auto;
  margin-left: auto;
}


.left_part {
  height: 40vh;
  position: relative;
  z-index: 0;
  background-image: url(img/book2.jpeg);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-color: #000;
  box-shadow: 0 50px 60px 0 rgba(0,0,0,.35);
  border-radius: 10px;
}


.left_part:hover {
-webkit-filter: blur(5px);
filter: blur(5px);
-webkit-transition: .5s ease-in-out;
position: relative;
z-index:0;
}

.left_part_content:hover {
color: #fed136;
position: relative;
z-index: 2;
}

.left_part-padding, .right_part-padding, .bottom_part-padding {
padding-left: 10px;
padding-right: 10px;
}

.left_part_content {
  color: white;
  font-family: "Raleway", Helvetica, Arial, sans-serif;
  text-transform: uppercase;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: .300em;
  margin-right: -.300em;
  text-align: center;
  vertical-align: middle;
  line-height: 40vh;
  position: relative;
  z-index: 2;
}
.left_part {
  height: 40vh;
  position: relative;
  background-color: #000;
  box-shadow: 0 50px 60px 0 rgba(0,0,0,.35);
  border-radius: 10px;
}

.left_part::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background-image: url(http://lorempixel.com/500/200/nature/1/);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-color: #000;
  border-radius: 10px;
}

.left_part:hover::before {
  -webkit-filter: blur(5px);
  filter: blur(5px);
}