jcadima
6/22/2017 - 7:28 PM

4 blocks with zoom background image

4 blocks with zoom background image


https://codepen.io/Grawl/pen/DovAI


<div class="hover-zoom" style="background-position: bottom right; background-image: url(&quot;https://c1.staticflickr.com/1/70/222707421_346dd12c17_z.jpg&quot;)">
  <p>
    Bottom right
  </p>
</div>
<div class="hover-zoom" style="background-position: bottom left; background-image: url(&quot;https://c4.staticflickr.com/4/3428/3901063146_21ebee43a1.jpg&quot;)">
  <p>
    Bottom left
  </p>
</div>
<div class="hover-zoom" style="background-position: top right; background-image: url(&quot;https://c2.staticflickr.com/8/7152/6784083185_3f575e5bdb_b.jpg&quot;)">
  <p>
    Top right
  </p>
</div>
<div class="hover-zoom" style="background-image: url(&quot;https://c4.staticflickr.com/8/7114/13963940252_cfa9c53e9a_c.jpg&quot;)">
  <p>
    Center by default
  </p>
</div>



<style>
  
.hover-zoom {
  float: left;
  margin: 0;
  height: 180px;
  width: 300px;
  -webkit-transition: all 0.3s ease-in-out;
  transition: all 0.3s ease-in-out;
  background-size: 110%;
  background-position: center;
  background-repeat: no-repeat;
  background-color: gray;
  position: relative;
}
.hover-zoom:hover {
  background-size: 100%;
}
.hover-zoom p {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  color: white;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.5em;
  margin: 0;
  box-sizing: border-box;
}
  
  
</style>