Hiển thị các bài đăng có nhãn Sonar Css. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Sonar Css. Hiển thị tất cả bài đăng

Thứ Năm, 2 tháng 1, 2020

Sonar Effect with CSS

Link web: https://codepen.io/thith/pen/vEOObL
Demo2: https://mangcut.vn/blog/2014-11-26-sonar-effect-with-css.html
**** HTML
<!-- http://www.mangcut.vn/blog/2014-11-26-sonar-effect-with-css.html -->
<div class="sonar-wrapper">
<div class="sonar-emitter">
    <div class="sonar-wave"></div>
  </div>
</div>

**** CSS
/* Make it looks good on CodePen */
html {
  background-color: #cef;
}
html, body, .sonar-wrapper {
  height: 100%;
}

/* Prevent scrollbars to appear when waves go out of bound */
.sonar-wrapper {
  position: relative;
  z-index: 0;
  overflow: hidden;
}

/* The circle */
.sonar-emitter {
  position: relative;
  margin: 32px auto;
  width: 160px;
  height: 160px;
  border-radius: 9999px;
  background-color: HSL(45,100%,50%);
}

/* the 'wave', same shape and size as its parent */
.sonar-wave {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  background-color: HSL(45,100%,50%);
  opacity: 0;
  z-index: -1;
  pointer-events: none;
}

/*
  Animate!
  NOTE: add browser prefixes where needed.
*/
.sonar-wave {
  animation: sonarWave 2s linear infinite;
}

@keyframes sonarWave {
  from {
    opacity: 0.4;
  }
  to {
    transform: scale(3);
    opacity: 0;
  }
}
#### JS$(".sonar-wave").on("webkitAnimationIteration oanimationiteration animationiteration", function(){
  $(this).css("background-color", colorize());
})

function colorize() {
  var hue = Math.random() * 360;
  return "HSL(" + hue + ",100%,50%)";
}