0

我一直在尝试使用角砌体。我一直在尝试做一些事情,例如将鼠标悬停在图像上时,图像会变暗,并且标题会在图像上更加暴露(高对比度)以便能够正确阅读。但是,当我尝试将鼠标悬停在图像上时,标题,或者在我的情况下我称之为标题,在我的图像中消失(或者显然也受到图像变暗的影响)。

要完全理解我的意思,请参阅StackBlitz 上的示例代码

我一直在尝试在纯 css 中执行此操作,以便在我的角度代码中只处理那些数据和屏幕转换(路由器链接)。我将样式留给 CSS 和其他库(即 Angular Masonry)

4

3 回答 3

1

问题是.feed-header位于过滤器后面,因此您需要z-index在该类上设置 a :

.masonry-item
.feed-container
.feed-header {
  position: absolute;
  width: 100%;
  padding: 10px;
  align-items: center;
  display: flex;
  z-index: 9;
}

此外,如果要使文本形成对比,则可能需要在悬停时将其设置为白色(与深色滤镜形成对比)。您可以这样做:

.masonry-item
.feed-container:hover
.feed-header {
  color: white;
}

这是一个 StackBlitz 演示

于 2018-08-27T07:06:21.930 回答
0

这个 stackblitz 应该可以工作

我所做的只是将标题放在图像之前并将其作为 SASS 添加到您的 CSS 文件中:

ngxMasonryItem {
  .feed-text {
    color: white;
    z-index: 9999;
  }
  &:hover {
    img {
      filter:  blur(2px) brightness(50%)
    }
  }
}

(删除您之前使用的过滤器)

在 HTML 中,声明顺序很重要,z-index.

于 2018-08-27T07:06:40.427 回答
0

试试这个演示

CSS 文件

.box {  

    cursor: pointer;  
    height: 468px;  
    float: left;  
    margin: 5px;  
    position: relative;  
    overflow: hidden;  
    width: 468px;  

}  

 .box img {  
    position: absolute;  
    left: 0;  
    -webkit-transition: all 300ms ease-out;  
    -moz-transition: all 300ms ease-out;  
    -o-transition: all 300ms ease-out;  
    -ms-transition: all 300ms ease-out;  
    transition: all 300ms ease-out;  
}  


.box .caption {  
    font-family: Tahoma;
    font-size: .5em;
    background-color: rgba(0,0,0,0.8);  
    position: absolute;  
    color: #fff;  
    z-index: 100;  
    -webkit-transition: all 300ms ease-out;  
    -moz-transition: all 300ms ease-out;  
    -o-transition: all 300ms ease-out;  
    -ms-transition: all 300ms ease-out;  
    transition: all 300ms ease-out;  
    left: 0;  
    opacity: 0;  
    width: 450px;  
    height: 450px;  
    text-align: left;  
    padding: 15px;
}  



 .box:hover .fade-caption {  
    opacity: 1;  
} 

HTML 文件

<div id="mainwrapper"> 

<!-- Image Caption 3 -->  
     <!-- Image Caption 3 -->  
    <div class="box">  
        <img id="image-3" src="https://www.w3schools.com/howto/img_avatar.png"/>  
        <span class="caption fade-caption">  
        <h3>Fade Caption</h3>  
        <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>  
        </span>  
    </div>

   <div class="box">  
        <img id="image-3" src="https://www.w3schools.com/howto/img_avatar.png"/>  
        <span class="caption fade-caption">  
        <h3>Fade Caption</h3>  
        <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit,sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>  
        </span>  
    </div>


</div>
于 2018-08-27T07:13:49.913 回答