придание непрозрачности изображению, размытие текста в css - PullRequest
1 голос
/ 13 января 2020

у меня есть изображение, при наведении на изображение текст будет отображаться, теперь я дал еще одну вещь, при наведении изображения фон будет размытым, и изображение должно отображаться, но изображение становится неясным, мой код похож на ниже:

.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>

Может кто-нибудь сказать, что не так в моем коде?

Ответы [ 2 ]

2 голосов
/ 13 января 2020

Не потрудился прочитать весь ваш код, но я думаю, что решил вашу проблему с ::after и использованием backdrop-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>
2 голосов
/ 13 января 2020

Ты выглядишь так?

.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>
...