cssbrightness

Overlay covers the div - keep fonts white


I trying to change the brightess of a div (not only an image brightness). Generaly there is an image in a div, description and caption, the main div background color is white. I want to show ovarlay div onmouse hover. Idea is to cover main div with overlay div. But now I getting only the image brightness change together with fonts. What I want to achieve is to cover the hole div while keeping font’s white z.

When I add a thumbnail brightness effect it also influence the fonts to became darker. how to do that keeping fonts white.

col-sm-6, caption, thumbnail classes are defined by bootstrap.

The code of:

                     <div  class="hovereffect thumbnail Staffinview1 delay1s">
                      <img src="./images/photo.jpg">

                      <div class="overlay">
                        <?php echo Person_description; ?>
                      </div>
                    
                      <div class="caption">
                        <h3>Name Surname</h3>
                      </div>

                      
                    </div>
                  </div>

The css code:

                 .thumbnail:hover {
                     transition:         all 0.5s  ease-in-out;
                    -moz-transition:    all 0.5s  ease-in-out;
                    -webkit-transition: all 0.5s  ease-in-out;
                    -o-transition:      all 0.5s  ease-in-out;
                    -ms-transition:     all 0.5s  ease-in-out;
                    box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.5);
                    }
                    
                    .hovereffect {
                      width: 100%;
                      height: 100%;
                      float: left;
                      overflow: hidden;
                      position: relative;
                      text-align: center;
                      cursor: default;
                    }

                    .hovereffect .overlay {
                      position: absolute;
                      overflow: hidden;
                      width: 80%;
                      height: 80%;
                      left: 10%;
                      top: 10%;
                      border-bottom: 1px solid #FFF;
                      border-top: 1px solid #FFF;
                      -webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
                      transition: opacity 0.35s, transform 0.35s;
                      -webkit-transform: scale(0,1);
                      -ms-transform: scale(0,1);
                      transform: scale(0,1);
                      color: #fff;
                    }

                    .hovereffect:hover .overlay {
                      opacity: 1;
                      filter: alpha(opacity=100);
                      -webkit-transform: scale(1);
                      -ms-transform: scale(1);
                      transform: scale(1);

                    }


                    .hovereffect img {
                      display: block;
                      position: relative;
                      -webkit-transition: all 0.35s;
                      transition: all 0.35s;
                    }

                    .hovereffect:hover img{
                      filter: url('data:image/svg+xml;charset=utf-8,<svg                         xmlns="http://www.w3.org/2000/svg"><filter id="filter"><feComponentTransfer color-interpolation-filters="sRGB"><feFuncR type="linear" slope="0.6" /><feFuncG type="linear" slope="0.6" /><feFuncB type="linear" slope="0.6" />                                                                        </feComponentTransfer></filter></svg>#filter');
                      filter: brightness(0.3);
                      -webkit-filter: brightness(0.3);
                    }

Solution

  • I believe You are trying to achieve a mask You can use z-index property and postion:absolute for that overlay div

    css rule

    .overlay {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0%;
      z-index: 0;
      transition: all 0.5s;
    }
    .overlay:hover {
      z-index: 1;
      background: rgb(173, 173, 173);
      opacity: 0.5;
    }
    

    Snippet below

    .thumbnail:hover {
      transition: all 0.5s ease - in -out;
      - moz - transition: all 0.5s ease - in -out;
      - webkit - transition: all 0.5s ease - in -out;
      - o - transition: all 0.5s ease - in -out;
      - ms - transition: all 0.5s ease - in -out;
      box - shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.5);
    }
    .hovereffect {
      width: 100 %;
      height: 100 %;
      float: left;
      overflow: hidden;
      position: relative;
      text - align: center;
      cursor: default;
    }
    .hovereffect.overlay {
      position: absolute;
      overflow: hidden;
      width: 80 %;
      height: 80 %;
      left: 10 %;
      top: 10 %;
      border - bottom: 1px solid# FFF;
      border - top: 1px solid# FFF;
      - webkit - transition: opacity 0.35s, -webkit - transform 0.35s;
      transition: opacity 0.35s, transform 0.35s;
      - webkit - transform: scale(0, 1);
      - ms - transform: scale(0, 1);
      transform: scale(0, 1);
      color: #fff;
    }
    .hovereffect:hover.overlay {
      opacity: 1;
      filter: alpha(opacity=100);
      - webkit - transform: scale(1);
      - ms - transform: scale(1);
      transform: scale(1);
    }
    .hovereffect img {
      display: block;
      position: relative;
      - webkit - transition: all 0.35s;
      transition: all 0.35s;
    }
    .overlay {
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0%;
      z-index: 0;
      transition: all 0.5s;
    }
    .overlay:hover {
      z-index: 1;
      background: rgb(173, 173, 173);
      opacity: 0.5;
    }
    <div class="hovereffect thumbnail Staffinview1 delay1s">
      <img src="./images/photo.jpg">
    
      <div class="overlay">
        <?php echo Person_description; ?>
      </div>
    
      <div class="caption">
        <h3>Name Surname</h3>
      </div>
    
    
    </div>