How to add 'shine' overlay to a div?

ⅰ亾dé卋堺 提交于 2019-12-05 21:48:55

Does something like this work for you: http://codepen.io/defo550/pen/Fcsxo

.photostrip {
  margin: 0 auto;
  width: 185px;
  background-color: #fff;  
  box-shadow: 0px 3px 7px 3px #333;
  padding: 7px;
  padding-bottom: 2px;

  /* Remove default list stylings*/
  list-style: none;

  /* provide a position context for our   pseudo element */
  li {
    position: relative;
  }

  img {
    display: block;  
    width: 175px;
    height: 120px;
    margin: 0 auto;
    margin-top: 6px;
    margin-bottom: 11px;
  }
}

/* overlay styles
  create pseudo element  
*/
.photostrip li:after {
        content: "";
        position: absolute;
       /* position above img */
        z-index: 5;

        width: 175px;
        height: 120px;
        top: 0;
        left: 5px;

/* overlay styles */
        background: linear-gradient(135deg, rgba(255,255,255,0.33) 0%,rgba(255,255,255,0.33) 60%,rgba(255,255,255,0) 61%,rgba(255,255,255,0) 100%);
      }

<ul class="photostrip">
 <li><img /></li>
 <li><img /></li>
 <li><img /></li>
</ul>

I put your images in an unordered list and then created a pseudo-element on the li (that wraps each image) that has a background gradient with the desired effect ( or close ) of your image above.

You could also target each li separately in the CSS to change up the background gradient.

i think this close to what you are looking for you just have to play with the numbers http://codepen.io/anon/pen/GDvju

i just added another layer and gave it a top left radius

body { background-color: #4b74db; }

.photostrip {
  margin: 0 auto;
  width: 185px;
  background-color: #000;  
  box-shadow: 0px 3px 7px 3px #333;
  padding: 7px;
  padding-bottom: 2px;
  position: relative;

  .overlay {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0px;
    left: 0px;
    /* This adds the nice overlay. */
  background: -webkit-linear-gradient(top, rgba(255,255,255,0.60) 0%,rgba(255,255,255,0.05) 100%);
  }
  .overlay2 {
    height: 100%;
    width: 50%;
    position: absolute;
    right: 0px;
    border-top-left-radius: 300px 600px;
    background: -webkit-linear-gradient(top, rgba(0,0,0,0.60) 0%,rgba(0,0,0,0.05) 100%);
  }


  img {
    display: block;    
    width: 175px;
    height: 120px;
    margin: 0 auto;
    margin-top: 6px;
    margin-bottom: 11px;
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!