Gaussian blur filter causes text above the affected image it to hide

前端 未结 1 1375
轮回少年
轮回少年 2021-01-24 16:19

I encountered a problem while trying to blur an image in CSS on my webpage: any element rendered above the affected image will hide during and after the procedure.

1条回答
  •  深忆病人
    2021-01-24 16:59

    Add position: relative to .imageLabel.

    body {
      margin: 0;
    }
    .imageFolder {
      float: left;
      display: block;
      width: calc(100vw / 3 - 0px);
      height: calc(100vw / 3 * 2 / 3 - 0px);
      border: 0px solid #444;
      overflow: hidden;
      text-align: center;
      vertical-align: middle;
    }
    .imageBox {
      display: inline;
      margin: 0 auto;
      width: 100%;
      height: 100%;
      overflow: hidden;
    }
    .imageBox img {
      display: inline;
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: all 0.2s ease-in;
    }
    .imageLabel {
      position: relative;
      display: inline-block;
      margin: calc(0px - 100vw / 3 * 2 / 3) auto 0;
      height: 40px;
      line-height: 40px;
      font-weight: 700;
      font-size: 24px;
      padding: 10px 40px;
      text-decoration: none;
      color: white;
      opacity: 0;
      text-align: center;
      vertical-align: middle;
      border: 1px solid white;
    }
    .imageFolder:hover > .imageBox img {
      width: calc(100% + 30px);
      height: calc(100% + 20px);
      margin: -10px -15px;
      transition: all 0.6s ease-out;
      filter: blur(4px);
    }
    .imageFolder:hover > .imageLabel {
      opacity: 1;
      transition: all 0.6s ease-out;
    }
    
      
    Charlotte

    0 讨论(0)
提交回复
热议问题