赋予图像不透明度,使 css 中的文本模糊

giving opacity to image making the text blur in css

我有一张图片,将鼠标悬停在图片上时,文字会显示,现在我再提供一件事,当图片悬停时,背景会变得模糊,图片应该会显示,但图片变得不清晰,我的代码如下所示:

.sip {
  z-index: 1;
  width: 90%;
  margin: 0px auto;
  text-transform: uppercase;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: normal;
  -webkit-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1);
  -webkit-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -moz-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -ms-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -o-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  visibility: hidden;
  opacity: 0;
}

.sip a {
  text-decoration: none;
  color: #046175;
  border: none;
}

.sip a:hover {
  color: #0e93b0;
}

.someby:hover {
  opacity: 0.3;
}

.someby:hover .sip {
  visibility: visible;
  opacity: 1;
}
<li class="someby" style="background-image: url('uploads/<?php echo $image['image'];  ?>')">
  <div class="post-meta">
    <a class="square-link-cover" href="main.php?editid=<?php echo $image['id']; ?>"></a>
    <div class="post-titles">
      <h2 class="sip">
        <a href="">
                        King
                      </a>
      </h2>

    </div>
  </div>
</li>

有人能告诉我我的代码有什么问题吗?

你是这个样子吗?

.sip {
  z-index: 1;
  width: 90%;
  margin: 0px auto;
  text-transform: uppercase;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: normal;
  -webkit-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1);
  -webkit-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -moz-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -ms-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -o-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  visibility: hidden;
  opacity: 0;
}

.sip a {
  text-decoration: none;
  color: #046175;
  border: none;
}

.sip a:hover {
  color: #0e93b0;
}

.someby:hover .sip {
  visibility: visible;
  opacity: 1;
}
<li class="someby" style="background-image: url('https://via.placeholder.com/150

C/O https://placeholder.com/')">
  <div class="post-meta">
    <a class="square-link-cover" href="main.php?editid=<?php echo $image['id']; ?>"></a>
    <div class="post-titles">
      <h2 class="sip">
        <a href="">
                        King
                      </a>
      </h2>

    </div>
  </div>
</li>

没有阅读你所有的代码,但我想我用 ::afterbackdrop-filter

的使用解决了你的问题

.sip {
  z-index: 1;
  width: 90%;
  margin: 0px auto;
  text-transform: uppercase;
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 2px;
  line-height: normal;
  -webkit-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1);
  -webkit-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -moz-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -ms-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  -o-transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  transition: opacity 340ms cubic-bezier(0.42, 0, 0.585, 1.23);
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  visibility: hidden;
  opacity: 0;
}

.sip a {
  text-decoration: none;
  color: #046175;
  border: none;
}
.someby {
  height:500px; /*Just for testing*/
  width:500px; /*Just for testing*/
  background-repeat:no-repeat; /*Just for testing*/
  position:relative; /*Needed for the After*/
  list-style: none; /*removing the dot.*/
  
}
.sip a:hover {
  color: #0e93b0;
}
/*Magic stuff..*/
.someby:hover::after {
  -webkit-backdrop-filter: blur(5px); /* Use for Safari 9+, Edge 17+ (not a mistake) and iOS Safari 9.2+ */
  backdrop-filter: blur(5px); /* Supported in Chrome 76 */

  content: "";
  display: block;
  position: absolute;
  width: 100%; height: 100%;
}

.someby:hover .sip {
  visibility: visible;
  opacity: 1;
}
<li class="someby" style="background-image: url('https://images.pexels.com/photos/1227520/pexels-photo-1227520.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500')">
  <div class="post-meta">
    <a class="square-link-cover" href=""></a>
    <div class="post-titles">
      <h2 class="sip">
        <a href="">
                        King
                      </a>
      </h2>

    </div>
  </div>
</li>