Membuat Lightbox Image Blogger Dengan Efek Zoom

Menjawab pertanyaan sahabat Kompi pada postingan sebelumnya ihwal zoom image postingan Blogger, alhasil aku mencoba lagi untuk memodifikasi lagi zoom image untuk gambar postingan Blogger tersebut menjadi menyerupai lightbox default Blogger.

Jika gambar postingan diklik maka akan muncul popup yang memperbesar gambar postingan. Untuk itu aku sedikit merubah jquery dan css dari zoom image sebelumnya. Dan alhasil tampak menyerupai pada gambar animasi GIF di bawah ini.



Jika Anda ingin mencobanya, silahkan ikuti langkah-langkahnya di bawah ini.

Silahkan simpan arahan css di bawah ini di atas arahan </head>, jikalau sebelumnya sudah memakai arahan css zoom image yang kemarin silahkan ganti dengan yang ini.

 <b:if cond='data:blog.pageType == &quot;item&quot;'>
<style>
/*<![CDATA[*/
.separator img {
  width: 100%;
  height: auto;
}

.separator.new {
  width: 80%!important;
  background: #fff;
  position: absolute!important;
  top: 10%!important;
  left: 50%;
  margin-left: -40%!important;
  -webkit-animation-name: zoomInUp;
  animation-name: zoomInUp;
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

.separator {
  width: 50%;
  position: relative;
  transition: all 100ms ease-in-out;
  cursor: pointer;
}

.separator:before {
  content: "\f00e";
  font-family: FontAwesome;
  position: absolute;
  bottom: 4px;
  right: 0;
  font-size: 2em;
  background: rgba(255, 255, 255, .6);
  padding: 10px;
  color: #444;
}

.separator.new:before {
  content: "×";
  font-family: Arial;
  position: absolute;
  font-weight: 400;
  bottom: 100%;
  top: -10px;
  line-height: 1;
  right: -30px;
  font-size: 2.5em;
  background: none;
  padding: 0;
  color: #fff;
}

.wrap_separator {
  text-align: center;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(0, 0, 0, .8);
  z-index: 99999
}

@media screen and (max-width:768px) {
  .separator.new {
    width: 90%!important;
    margin-left: -45%!important;
  }
  .separator.new:before {
    top: -35px;
    right: -3px;
  }
}

@-webkit-keyframes zoomInUp {
  0% {
    opacity: 0;
    -webkit-transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0);
    transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0);
    -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190);
    animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190);
  }
  60% {
    opacity: 1;
    -webkit-transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
    transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
    -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
  }
}

@keyframes zoomInUp {
  0% {
    opacity: 0;
    -webkit-transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0);
    transform: scale3d(.1, .1, .1) translate3d(0, 1000px, 0);
    -webkit-animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190);
    animation-timing-function: cubic-bezier(0.550, 0.055, 0.675, 0.190);
  }
  60% {
    opacity: 1;
    -webkit-transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
    transform: scale3d(.475, .475, .475) translate3d(0, -60px, 0);
    -webkit-animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
  }
}
/*]]>*/
</style>
</b:if>


Kemudian silahkan simpan arahan javascript di bawah ini di atas arahan </body>, jikalau sebelumnya sudah memakai arahan javascript zoom image yang kemarin silahkan ganti dengan yang ini.

 <b:if cond='data:blog.pageType == &quot;item&quot;'>
<script type='text/javascript'>
//<![CDATA[
function resizeThumbsmall(e){for(var r=document.querySelectorAll(".separator img"),s=0;s<r.length;s++)r[s].src=r[s].src.replace(/\/s200/,"/s"+e),r[s].width=e,r[s].height=e}function resizeThumbmedium(e){for(var r=document.querySelectorAll(".separator img"),s=0;s<r.length;s++)r[s].src=r[s].src.replace(/\/s320/,"/s"+e),r[s].width=e,r[s].height=e}function resizeThumblarge(e){for(var r=document.querySelectorAll(".separator img"),s=0;s<r.length;s++)r[s].src=r[s].src.replace(/\/s400/,"/s"+e),r[s].width=e,r[s].height=e}function resizeThumbextralarge(e){for(var r=document.querySelectorAll(".separator img"),s=0;s<r.length;s++)r[s].src=r[s].src.replace(/\/s640/,"/s"+e),r[s].width=e,r[s].height=e}$(".separator a > img").unwrap(),$(".separator").each(function(){$(this).click(function(){$(this).parent().is("div")?$(this).removeClass("new").unwrap():$(this).addClass("new").wrap('<div class="wrap_separator"></div>')})}),resizeThumbsmall("1600"),resizeThumbmedium("1600"),resizeThumblarge("1600"),resizeThumbextralarge("1600");
//]]>
</script>
</b:if>


Dan pastikan blog Anda sudah memakai jquery library dan font awesome.

Cara mendapat font awesome kini berubah lho, silahkan simak di sini:


Sumber https://www.kompiajaib.com/

0 Response to "Membuat Lightbox Image Blogger Dengan Efek Zoom"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel